I would suggest using arrays and not variables. This will make things a lot easier.
Suppose you store each command in 'char' variable. Then to store up to 30 commands you need an array of 'char's:
char commands[30];
char commands_num = 0; // this is the actual number of commands
storing commands will look something like this:
// receive the new command here
char new_command = ...
// add the command to you commands array
if ( commands_num < 30 )
{
commands[commands_num] = new_command;
++commands_num;
}
else
{
// no space left for commands
}
Executing the commands will look like:
for(int i=0; i<commands_num; ++i)
{
char current_command = commands*;*
- // put here the code to execute the current_command*
}
Note, the executing runs from the beginning of the array till the number of commands stored in it in the program mode.
HTH