LET s$ = "1+1"
LET s$ = CHR$(_VAL) + """" + s$ + """"
LET r = EvalBasic(s$)
How do I get the return value of VAL ?
LET s$ = CHR$(_VAL) + """" + s$ + """"
LET r = EvalBasic(s$)
How do I get the return value of VAL ?
Where is the return value? (solved but with exit error)

LET s$ = "1+1"
LET s$ = CHR$(_VAL) + """" + s$ + """" LET r = EvalBasic(s$) How do I get the return value of VAL ?
#include <basic.bas>
#define _LET 241 #define _VAL 176 LET exp$ = "3/4" PRINT exp$;"= ?" LET s$ = CHR$(_LET, CODE "r",CODE "=",_VAL) LET s$ = s$ + """" + exp$ + """" EvalBasic(s$) LET vars = PEEK 23627+256*PEEK 23628 ' 23799 IF vars <> 23799 THEN PRINT "Error: Vars addr at ";vars DIM w AS FLOAT AT 23799+1 PRINT CHR$(PEEK 23799);"= ";w Output: r= 0.75 This works but when program exits I got this error message: ? ?E, 30:1
I gave up using EvalBASIC and, with a few tricks, I managed to use VAL like on the ZX Spectrum.
Like: s$ = INPUT(32) ' example: "SIN(x*10)+5/(1+x*x)" s$ = FixExpression(s$) y = VAL s$
Sorry, the forum is (again) under severe spam attack. :(
I understand that FixExpression converts SIN to its token?
11122023, 05:44 PM
Yes, convert SIN to its token and convert x to its value.
11122023, 06:01 PM
ZX Basic VAL calls ROM's VAL which in turns evaluates complex (BASIC) expressions.
The corruption message you show above also happened to me in 128K mode, but not in 48K mode... Which mode did you use?
11122023, 06:04 PM
48K .

« Next Oldest  Next Newest »
