I'm passing a boolean expression in terms of some variable I
into a TI-BASIC program that manipulates I
, but the boolean expression is only evaluated once - at the beginning of the program's execution.
Here is a sample program:
Prompt J
0 -> I
Lbl 1
1 + I -> I
Disp I
If J
Then
Goto 2
Else
Goto 1
End
Lbl 2
End
(This is not the actual program I'm writing, which is more complicated and thus cannot use a for loop; the above program could obviously be written more elegantly with a for loop.)
We increment I
by 1, starting with the number 0. After every increment, we check whether J
is true, and if so, we stop.
If I pass in J=I≠5
, the program stops after printing 1
.
If I pass in J=I=5
, the result is not expected. I intend for the program to stop when I=5
is true, but instead the program continues indefinitely. This means that J
is only evaluated at the beginning of the program.
Is it possible to reevaluate J
in every execution of that loop?
I assume that J
is being replaced with 0
and 1
as soon as it is passed in. To rephrase my question, is it possible to input/keep the boolean expression as an unevaluated string/literal? Then I would just call something like eval(J)
within the program.