A function to evaluate expressions
Brought to you by:
kerravon86,
tcamp
I miss one powerful feature of X11-Basic and other BASIC implementations: read
can evaluate expressions. Example:
let a%=100
read b%
print b%
data a%
This feature is very useful to init big arrays whose contents depend on certain values.
As an alternative, strings can be used instead, and then evaluated:
let a%=100
read b$
led b%=eval(b$)
print b%
data "a%"
But I've found no such evaluating function in the documentation: val()
and num()
only
accept literals, just as read
does.
The only alternative left is to init the arrays explicitly, i.e. not from data
lines, which is wordy and less convenient.
A read
command capable of evaluating expressions would be great, but a function to evaluate expressions would be better, because it would be usable in any context.
I am not aware of any BASIC dialect whose "read" behaves that way, and I have no plans to add the X11-BASIC dialect to Bywater BASIC at this time.
It's not a feature of classic/standard BASIC. I've found it in Sinclair BASIC, SuperBASIC, SBASIC and others.
Anyway, a function to evaluate expressions would be more versatile.
Of course. I didn't suggested that. Besides, that would be nonsense, because X11-Basic is not an old classic dialect, but a modern implementation under active development.