Field Service Manual December 2003
Page 27 of 276
208 13 8 / ? / . <> ----> 1208
In addition to these arithmetic operators, the following logical operations are possible:
>, >=, < =, ==, < >. These words also pop two numbers from the stack and push a
zero if the logical operation gives a FALSE result, and push a one if the result is
TRUE.
Examples
3 4 == . ---> 0
3 4 > . ---> 0
3 4 <= . ---> 1
3 2 + 5 == . ---> 1
LTL also knows loop constructs:
number DO .... LOOP
DO ...... WHILE
DO ...... UNTIL
DO ...... TILKEY
The LOOP word decreases the number on TOS and goes on with the word after the
DO word if the TOS is not zero. If TOS is zero the words after LOOP are executed. It
is important that the words between DO and LOOP do not leave any supplementary
data on the stack because this disturbs the loop counter.
Examples
10 DO ? LOOP
This is a correct loop construct, it will print the numbers 10 up to 1 on the screen.
10 DO . LOOP
This is an error because the .-word will print the 10 but also removes the loop counter
from stack. The LOOP word will find nothing on the stack and this will result in a
stack empty error.
10 DO 1 ? LOOP
This is also incorrect, because the ?-word leaves the 1 on the stack, the LOOP word
will decrease this 1 and end the loop.
The WHILE word repeats the instructions between DO and WHILE if the number on
the stack does not equal zero. If the TOS-number is zero, the loop stops.
The UNTIL word repeats the loop until the number on the stack is not equal to zero.
Both WHILE and UNTIL words usually follow after a logical operation.
DO (commands) TILKEY allows repeated execution of commands put between the
words, until a key is pressed. This sets a "flag", which will cause the loop to be exited
after completion of the commands, so this may take some time!