Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
09/28/05 18:56
Read: times


 
#101693 - Recognisable string
Responding to: ???'s previous message
Guy Lavoie said:
That is the "standard" way that I thought I had to use, but I'm trying to avoid the long list of "jc crt" after each character fetch, especially since the destination address will often be more then a short jump can handle, creating even messier code. My main (calling) routine checks each character as they come in to look for a recognizable string and if an unexpected carriage return happens midway through the string, I just want to abort the whole thing.


IMHO you should look in more detail at the 'look for a recognisable string' code in order to avoid the 'long list of jc crt after each character fetch'. I would suggest you look at using a loop. e.g.

#define CR 0x0D
#define MAXSTRLEN 10 // Max string length expected

char tempstr[MAXSTRLEN];
char ch;

tempstr[0] = '/0';
i = 0;
while( (ch = getch()) != CR)
{
   tempstr[i++] = ch;
   tempstr[i] = '/0'   // add new char to string
   if (valid_command(tempstr) break;
}

Basically, if the next char is not CR it gets added to the string and valid_command is called. This routine checks the passed string for valid commands and does not have to worry about embedded CRs. Obviously this is very rough but I hope you get the idea.

Ian

List of 24 messages in thread
TopicAuthorDate
RET to a different address            01/01/70 00:00      
   here is how pseudocode            01/01/70 00:00      
      RET to a different address            01/01/70 00:00      
         no flaw, but 1.000.000 gotchas            01/01/70 00:00      
            That's what I wanted to know            01/01/70 00:00      
               Yes            01/01/70 00:00      
               "clever"            01/01/70 00:00      
                  OT: my wife            01/01/70 00:00      
         no flaw, but seriously not recommended            01/01/70 00:00      
            experience            01/01/70 00:00      
               reload SP            01/01/70 00:00      
                  restoring stack            01/01/70 00:00      
         Recognisable string            01/01/70 00:00      
      named return value            01/01/70 00:00      
   Bad Practice            01/01/70 00:00      
      Well phrased            01/01/70 00:00      
   What I am doing with it            01/01/70 00:00      
      try...catch            01/01/70 00:00      
         setjmp / longjmp            01/01/70 00:00      
         when to try ... catch            01/01/70 00:00      
            the borderline            01/01/70 00:00      
               Promises            01/01/70 00:00      
                  who cares if an exceptiom is "acceptable            01/01/70 00:00      
      Parsing input data            01/01/70 00:00      

Back to Subject List