ProvideX V8.20 > Language Reference > 2. Directives
157
Examples
Simple IF Statement
00010  INPUT "Enter a number: ",a
00020  INPUT "Enter another: ",b
00030  IF a>b \
THEN PRINT "First one is larger";
STOP
00040  IF b>a \
THEN PRINT "Second one is larger";
STOP
00050  PRINT "Both numbers are the same"
00060  STOP
-:RUN
Enter a number: 123.45
Enter another: 123.56
Second one is larger
Compound IF Statement:
00010  FOR i=1 TO 30
00020  PRINT i," is divisible by ",
00030  IF MOD(i,2)=0 \
THEN IF MOD(i,3)=0 \
THEN PRINT "both" \
ELSE PRINT "2" \
ELSE IF MOD(i,3)=0 \
THEN PRINT "3" \
ELSE PRINT "neither"
00040  NEXT i
00050  STOP
RUN
1 is divisible by neither
2 is divisible by 2
3 is divisible by 3
4 is divisible by 2
...
28 is divisible by 2
29 is divisible by neither
30 is divisible by both
Multiple Line IF Statement.
00010
IF A = B THEN {
00020
LET C = D
00030
PRINT "A equals B"
00040
} ELSE {
00050
LET X = Y
00060
PRINT "A was not identical to B"
00070
}