Where is the return value? (solved but with exit error) - Printable Version +- Forum (https://www.boriel.com/forum) +-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12) +--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11) +---- Forum: Help & Support (https://www.boriel.com/forum/forumdisplay.php?fid=16) +---- Thread: Where is the return value? (solved but with exit error) (/showthread.php?tid=2492) |
Where is the return value? (solved but with exit error) - zarsoft - 11-08-2023 LET s$ = "1+1" LET s$ = CHR$(_VAL) + """" + s$ + """" LET r = EvalBasic(s$) How do I get the return value of VAL ? RE: Where is the return value? (solved) - zarsoft - 11-08-2023 #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 RE: Where is the return value? (solved but with exit error) - zarsoft - 11-09-2023 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$ RE: Where is the return value? (solved but with exit error) - boriel - 11-12-2023 Sorry, the forum is (again) under severe spam attack. :-( I understand that FixExpression converts SIN to its token? RE: Where is the return value? (solved but with exit error) - zarsoft - 11-12-2023 Yes, convert SIN to its token and convert x to its value. RE: Where is the return value? (solved but with exit error) - boriel - 11-12-2023 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? RE: Where is the return value? (solved but with exit error) - zarsoft - 11-12-2023 48K . |