Dave,
ABC#### C NN - 2 digits is an altitude in thousands of feet
ABC#### C NN X - the X modifier expedites the altitude change (where
possible/reasonable)
ABC#### C NNN - 3 digits is a heading in degrees
ABC#### C NNN L (or R) - where a course change follows the shortest turn, L
or R modifier makes the turn direction explicit
ABC#### C $$$ - where a valid beacon is given, the aircraft will fly to that
beacon
ABC#### S NNN - change speed to...
ABC#### L XXX - cleared to land on runway XXX (eg: 14L)
ABC#### T - clearance to take off (an altitude must be set first
How would you handle more than one command per plane? (I.e. "Climb to xxx and turn left to yyy")

Your examples are not clear to me: I guesst the "ABC" part is some sort of plane identification? A flight #?

A typical approach in any language would be a function that breaks a line into syntactical pieces ("tokens") and returning the next token (here: anything separated by white space) from the input line as a string. Outside that, you'd have a lexical analyzer that checks whether the token you just got matches anything you'd expect.

Your second line example would be handled lke:
"InitParser("ABC#### C N X)
x$ = getNextToken () - would return "ABC####", your analyzer checks whether this is a valid flight # the next "x$=getNextToken()" would return "C", you accept this because it is valid here the next "x$=getNextToken()" would return the new altitude - Your analyzer checks for valid numerical value
the next "x$=getNextToken()" would return  the "X" and
the next one an empty string to signal to the analyzer that you're done with this line.

obviously, the getNextToken function would need some non-local variables to keep track of where in the input line it currently is Those would need to be initialized along with the input line in initParesr for each new command line.

The analyzer would be programmed as "finite state machine" that holds a non-local variable on "where I am currently" - i.e a state value that tells tehe analyzer what to expect next.

Hope this helps
Tobias
_______________________________________________
QL-Users Mailing List
http://www.q-v-d.demon.co.uk/smsqe.htm

Reply via email to