Thread: Needing a rare code!

  1. #1
    Registered User
    Join Date
    Nov 2004
    Posts
    1

    Question Needing a rare code!

    I don't know if this code is rare, but I wanted your attention C++ Freaks! ^^

    Now to the point, I want to write a program that I can command doing stuffs, like I write:"Count", and it says "Which arithmetic? Add, Sub,Div,Multi..". And I write that and so on. But I don't know what to write to make it do that, I know that CHAR is using for reading and writing CHARacters, but how doe I do to make it READ my WORDS and UNDERSTAND if "Count" goto counting-mode and so on. I have tried this noob code:

    if(command == "Count")
    goto count;

    ^
    I think that code is a BIG LOL for most of you, but I think u get the point, what I want to do, I can write a command so I can do other things, please write an simple example how to create uhm.... whatever -> "Word-Commands". :- )

    Many Greetings, A Noob Who Made His Own Mathcounter in C++!

  2. #2
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    std::string
    getline()
    if()
    functions

    Ok thats about all the help I'm gonna give until you actually type out a meaningful question that includes real code.
    Last edited by Thantos; 11-10-2004 at 06:18 PM.

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    It sounds like what you want to do is write scripting language and write an interpreter for it. There have been many people wanting to do projects like this. You can look for some Open Source projects on google (it's not open source, but an example is PHP - you write a script, and the program executes it), or do a search of these boards and look at the answers other people have gotten.

    To clarify, the difference between a scripting language and something like C++, is that C++ is generally compiled. It is permanently translated into machine code, and then executed in that form. Scripting languages (like JavaScript, PHP, and arguably BASIC) are always kept in human-readable, source code form. When the program is to be run, the interpeter reads that script and acts on the instructions. No long-term translation takes place.

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    it's not open source, but an example is PHP - you write a script, and the program executes it
    PHP is licensed under an Open Source license.
    The source (in C) can be downloaded from:
    http://www.php.net/downloads.php
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    yeah, and please don't point people towards PHP unless you want to explain to them how to set up an http server on their machine...
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  6. #6
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    PHP is licensed under an Open Source license.
    Ahh... I stand corrected. Thank you very much for the link.

    yeah, and please don't point people towards PHP unless you want to explain to them how to set up an http server on their machine...
    I'm pretty sure you don't need a web server to run PHP.

  7. #7
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Actually you do. PHP is a server side scripting language. It is proccessed by the web server and outputed as normal text which can then be interpeted by the browser as html.

  8. #8
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    Oh really? Okay. I always thought the server sent a system call to the PHP program with the PHP file as an argument and got the output sent back somehow.

  9. #9
    Registered User
    Join Date
    Nov 2004
    Location
    Slovenia, Europe
    Posts
    115
    here's the exact PHP processing:

    the client browser send a request for a *.php file to a HTTP server. A server looks for module/CGI library and send a request, which includes client request to a PHP preprocessor, which processes all variables, executes SQL queries, ... The PHP Preprocessor then outputs a HTML code which is created on base of PHP file and sends it to a HTTP server. Then, HTTP server sends the HTML file to a client browser, which processes HTML syntax into GUI

  10. #10
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    New York
    Posts
    1,905
    For a php server on windows home, I use a nifty little thing called Xampp. It's an apache server that has php/sql/ftp/perl/mercurymail and a webalizer all built in. And it's free, and it works, really nicely. You can set it up and actually use your computer as a host (though I haven't figured out how to route IPs to my computer through my router yet.....it only seems to work when I'm plugged directly in to the modem which sucks cuz then my mom can't use the net..... )

  11. #11
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    I'm thinking red squares here.

  12. #12
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    If you just want something simple, go with Thantos' suggestion (i.e. the list of things he told you to lookup). If you want a full blown scripting language, then it is going to be quite a project. You can certainly find example source code for scripting languages (e.g. Python). There is also a parser library in Boost (www.boost.org) called Spirit which may be of some use. Realistically, if is easier to just go with the straight-forward ('if command is X then do Y') route.
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  13. #13
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    Quote Originally Posted by jverkoey
    For a php server on windows home, I use a nifty little thing called Xampp. It's an apache server that has php/sql/ftp/perl/mercurymail and a webalizer all built in. And it's free, and it works, really nicely. You can set it up and actually use your computer as a host (though I haven't figured out how to route IPs to my computer through my router yet.....it only seems to work when I'm plugged directly in to the modem which sucks cuz then my mom can't use the net..... )
    I set up an apache server on my box, and have the same problem... I don't have direct access to the modem... I would try giving my system full access to the router and then sharing the connection to the other computer, but my father has control over that...
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  14. #14
    Registered User
    Join Date
    Sep 2004
    Posts
    197
    Quote Originally Posted by Thantos
    Actually you do. PHP is a server side scripting language. It is proccessed by the web server and outputed as normal text which can then be interpeted by the browser as html.
    Actually, PHP comes with a executable interpreter just like perl does. You can run it from command line, and use it for many other tasks. Heck, people have even made a library for GTK so you can make programs in php that have a GTK interface.
    If any part of my post is incorrect, please correct me.

    This post is not guarantied to be correct, and is not to be taken as a matter of fact, but of opinion or a guess, unless otherwise noted.

  15. #15
    Registered User
    Join Date
    Dec 2004
    Posts
    2
    I have more experience scripting PHP than c++ but I use php for everyday things on my windows xp machine with NO http server, php includes php.exe that can be run with command line arguments and used to execute script outside of the client - server environment its NORMALLY found in, but that by no means states that is how it is always to be used. I tend to think outside of the box and have a php script that renames mp3's based on thier id3tags. that should give you an example of the things that can be done without an http server
    the only downside is you must use php at the commandline level, not with those silly windows shortcuts.
    this is my 2cents, i just know what I know.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Needing Assistance;Unreachable code in function main()
    By Mehtabyte in forum C++ Programming
    Replies: 5
    Last Post: 11-19-2008, 02:27 PM
  2. Newbie needing help with basic code!
    By TeZ258 in forum C++ Programming
    Replies: 4
    Last Post: 11-03-2007, 08:35 PM
  3. Values changing without reason?
    By subtled in forum C Programming
    Replies: 2
    Last Post: 04-19-2007, 10:20 AM
  4. Updated sound engine code
    By VirtualAce in forum Game Programming
    Replies: 8
    Last Post: 11-18-2004, 12:38 PM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM