fixed nested if logic
This commit is contained in:
+1
-1
@@ -171,7 +171,7 @@ Conditionally execute the statement that follows the expressions with the relati
|
||||
3. Set the string `EXPR1` to everything from the start of `STMT` to the character at position `ROPOS - 1` inclusively.
|
||||
4. Set the string `REST` to everything from the position `ROEND + 1` to the end of `STMT` inclusively.
|
||||
5. Initialize the integer position variable `THENPOS` to -1.
|
||||
6. Pick the next keyword `KW` from this list in this particular order: `THEN LET = RETURN GOSUB INPUT PRINT GOTO END IF`. Go to step 11 when the list is exhausted.
|
||||
6. Pick the next keyword `KW` from this list in this particular order: `THEN IF LET = RETURN GOSUB INPUT PRINT GOTO END`. Go to step 11 when the list is exhausted.
|
||||
7. Set `THENPOS` to the first position of the currently iterated keyword `KW` inside `REST`. If not found, go to step 6.
|
||||
8. If `KW` is equal exactly to `=`, decrement `THENPOS` by 1.
|
||||
9. Copy the value of `THENPOS` to another integer variable, `RESTPOS`.
|
||||
|
||||
@@ -150,7 +150,7 @@ proc lttb_IF {stmt} {
|
||||
set relop [string range $stmt $ropos $roend]
|
||||
set expr1 [string range $stmt 0 $($ropos-1)]
|
||||
set rest [string range $stmt $($roend + 1) end]
|
||||
foreach kw {THEN LET {=} RETURN GOSUB INPUT PRINT GOTO END IF} {
|
||||
foreach kw {THEN IF LET {=} RETURN GOSUB INPUT PRINT GOTO END} {
|
||||
set thenpos [string first $kw $rest]
|
||||
if {$thenpos > -1} {
|
||||
if {$kw eq {=}} {incr thenpos -1}
|
||||
|
||||
Reference in New Issue
Block a user