|
|
|
|
|
|
|
|
|
|
I did post my code and the error i am getting, which is located on the last post of the first page. |
ReadCommands( currentline, CommandList, nRepeats);
i don't understand read command because you have a vector in a vector and Command inside and not string. |
i tried the following
which shows the numbers but then gives a runtime error. |
|
|
how do i store the action and the value to a curcmd vector. e.g. if i wanted to obtain the action of the first element it would be forward and if i wanted the value element i would get 9. i know you did this with the vector< vector<Command>> but it didn't work as i gave the error in last post of first page. |
Row 0 should be FORWARD 9 Row 1 should be LEFT 8 FORWARD 50 but looking in CommandList[1] cout<<CommandList[1]<<endl; gives FORWARD 9LEFT 8 instead of LEFT 8FORWARD 50 |
act.str(std::string());
before doing act<<Action<<' '<<value;
|
|
I did post my code and the error i am getting, which is located on the last post of the first page. andywestken and me told you where the mistake was and how to correct it: ReadCommands( currentline, CommandList, nRepeats); |
My "Command" structure simply contains the string indicating the action to perform and the value associated with it. It's easier to manipulate that way. You wanted to store it in an array of rows. Since the rows are also arrays, it's an array of array. I implemented it using vectors because it's simpler. |
struct Instruct { int Num; string Comnd; }; Instruct Command; Command.Comnd=Action; Command.Num=value; CommandList.push_back(Command) |
|
|
|
CommandList.Push_Back(Command);
must be inside the if( string("REPEAT") == Action )
.Command.push_back( std::string () );
appends an empty string. I think what you really want is to empty the vector. It's done with Command.clear();
|
|
|
|
|
|
|
|
vector<Instruct> Command; |
i was thinking of instead of performing draw function, set up a class which takes a vector, which would be pushing all the command that has to be performed to the back and then a global object of the class would have to be declared then in draw you can loop through the contents of the vector. what do you think. |
|
|
|
|