Menu

#4 A function to evaluate expressions

open
nobody
None
5
2017-09-27
2017-08-22
Marcos Cruz
No

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.

Discussion

  • AF5NE

    AF5NE - 2017-09-25

    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.

     
  • Marcos Cruz

    Marcos Cruz - 2017-09-27

    I am not aware of any BASIC dialect whose "read" behaves that way,

    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.

    I have no plans to add the X11-BASIC dialect to Bywater BASIC at this time.

    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.

     

Log in to post a comment.