Results 1 to 3 of 3

Thread: Strings...

  1. #1

    Thread Starter
    Hyperactive Member Warmaster199's Avatar
    Join Date
    Aug 2000
    Location
    Canada
    Posts
    306

    Question Strings...

    This is a long question: PLEASE continue reading.

    ||
    ||
    ||
    \/


    How do I use strings. I know you need a "char *something;" and I have included the string.h file, but I never needed to use strings.

    Now what I will do is send strings via radio frequency for a network of robots to communicate with eachother in a few kilometer radius. These robots will never be this far apart, but I would like range. Anyways, these are the strings I need to decipher:

    Command[Robot_Name]:function('argument1', 'argument2');

    "Command" ---> This will be the key word so my program knows a command is being issued.

    [Robot_Name]: ---> This is the name of the robot that will be recieving this command. Robots SHOULD ignore a command that is not issued to them. If this is left blank such as [], then the command is issued to all robots on the RF network.

    function( ---> This is the name of the command that is being issued. The bracket means that the arguments are to follow.

    'argument1' ---> Argument number 1. Anything that is in between the apostrophies gets assigned to a variable.

    , ---> Just like in C/C++, this means that another arguement is to follow.

    'arguement2' ---> Same as arguement1.

    ); ---> Ends function. Tells program that the PLL's(phase-lock-loop) Radio-Frequency signal is finished. Tells program that the PLL is ready to recieve the next command.



    Basically, all I need to know is how I can cut up strings. I need to keep cutting up the strings like the following for example with [robot_name]:

    char *roboname;
    //Get the command and the first "["
    while(something !="]")
    {
    //Do something to get the recipient robot's name. Continue
    //getting characters until the character encounted is a "]"
    roboname=roboname+ characters in order that were found before "]";
    }

    if (next char != ":")
    return;

    //get the robot's next command...

    and so on and so forth... How would I do this!? This seems easy, yet I can't do it because I don't know how to do this stuff that is commented.
    Designer/Programmer of the Comtech Operating System(CTOS)

  2. #2
    Zaei
    Guest
    Include "string". Note there is not ".h". Just "#include <string>". This will allow you to use "std::string" in your program. This gives you the ability to add characters to strings, assign strings, etc, without having to worry about exactly how it is stored. I recommend looking into the basic_string documentation in the MSDN.

    Z.

  3. #3

    Thread Starter
    Hyperactive Member Warmaster199's Avatar
    Join Date
    Aug 2000
    Location
    Canada
    Posts
    306
    There is a problem: I need to know how to do this. I forgot to say that this is not DOS. It's for a robotics OS that can read FAT Filesystems(Currently FAT12(<32MByte). Working on FAT16(<8GByte), manage memory, multitask for simultanious locomotion, sensor gathering, and AI scripts. This RF-PLL function will be massive. There will be a function library as well. Once the string = a certain function, that function is called with the given arguements. Information is then sent back to the other robo.

    I will check the string info at MSDN.
    Designer/Programmer of the Comtech Operating System(CTOS)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width