eval Function (eval$) for SuperBASIC (Job 0,0 only?) (does <EDIT>or does not(?)</EDIT> work in Minervas MultiBASICs)

Anything QL Software or Programming Related.
User avatar
janbredenbeek
Super Gold Card
Posts: 683
Joined: Wed Jan 21, 2015 4:54 pm
Location: Hilversum, The Netherlands
Contact:

Re: eval Function (eval$) for SuperBASIC (Job 0,0 only?) (does <EDIT>or does not(?)</EDIT> work in Minervas MultiBASICs)

Post by janbredenbeek »

ql_freak wrote: Sat Jun 28, 2025 1:45 am There is no code (not even unvectored) in QDOS, which can evaluate a string as an expression. I assume if you have a line like:

PROCname expression (or FuNcname(expression))

e.g.:

myProc sin(pi/6)*2

SuperBASIC tokenizes the expression (sin(pi/6)*2) and then there seems to be a (none vectored) routine, which can evaluate this tokenized expression.

There (IMHO) must be such a code in QDOS else the above code (myProc ...) shouldn't be possible.
In Minerva, there is a more or less undocumented vector (CA.EVAL, $14E) which evaluates a tokenised expression. The description in the Minerva manual is incomplete, but the source code contains an accurate description about its parameters.

But in order to evaluate an expression in a string, you have to parse (and tokenise) it first, which isn't possible from a running interpreter unless you resort to the CONTINUE trick as mentioned. A neater way would be to feed this string into a second interpreter under Minerva or SMSQ/E which tokenises and evaluates it. There are also obscure vectors to parse a S*BASIC line into a tokenised line (see this source file near the end on how to use these).

One remaining problem will be the use of variables, for which the values have to be substituted from the calling program since the second interpreter doesn't know about them.

Well, I think I've found a new programming challenge... ;)


User avatar
ql_freak
Super Gold Card
Posts: 517
Joined: Sun Jan 18, 2015 1:29 am

Re: eval Function (eval$) for SuperBASIC (Job 0,0 only?) (does <EDIT>or does not(?)</EDIT> work in Minervas MultiBASICs)

Post by ql_freak »

janbredenbeek wrote: Sat Jun 28, 2025 10:50 pm One remaining problem will be the use of variables, for which the values have to be substituted from the calling program since the second interpreter doesn't know about them.
Yep! That's the problem. I have had also written a VAL function for SuperBASIC (when I have had using my real QL). It's unfortunately only on the harddisk of my old QL (which hasn't been switched on for over 20 years - DUNNO if the harddisk, a RLL harddisk with Dirk Steinkopf Interface will still be working - AND HAVE CURRENTLY NO TIME TO TEST IT). But that was also my problem. Numeric expressions could be calculated perfectly, but of course without the possibility to use variables of the interpreter which calls the VAL-function in the second interpreter. (BTW: Minerva has had MultiBASIC long before QPC/QPC2, like e.g. the History device from Boris Jakubith, a friend of mine.)
Well, I think I've found a new programming challenge... ;)
Yeah! This would be great. I'm currently (not so really, as long as it is so hot - then I go swimming) working on how to get parameters of SuperBASIC functions directly (without using CA.GETSTR, ...). Unfortunately not as easy, as I have thought.

Next thing to do: Use C1MON Professional Monitor with symbolic debugging. I can use C1MON debugger (normal one), but haven't tried symbolic debugging with Professional Monitor yet.


http://peter-sulzer.bplaced.net
GERMAN! QL-Download page also available in English: GETLINE$() function, UNIX-like "ls" command, improved DIY-Toolkit function EDLINE$ - All with source. AND a good Python 3 Tutorial (German) for Win/UNIX :-)
User avatar
janbredenbeek
Super Gold Card
Posts: 683
Joined: Wed Jan 21, 2015 4:54 pm
Location: Hilversum, The Netherlands
Contact:

Re: eval Function (eval$) for SuperBASIC (Job 0,0 only?) (does <EDIT>or does not(?)</EDIT> work in Minervas MultiBASICs)

Post by janbredenbeek »

Working example on SMSQ/E:

Code: Select all

5000 DEFine FuNction eval(e$)
5010   LOCal chan,result
5020   chan=FOP_OVER(ram1_eval_in_bas)
5030   PRINT#chan;"_chan=FOP_OVER(ram1_eval_out)"
5040   PRINT#chan;"_result=";e$;":PRINT#_chan;_result"
5050   PRINT#chan;"CLOSE#_chan"
5060   CLOSE#chan
5070   EW ram1_eval_in_bas
5080   chan=FOP_IN(ram1_eval_out)
5090   INPUT#chan;result
5100   CLOSE#chan
5110   RETurn result
5120 END DEFine eval
Of course this doesn't support variables yet.
I've tried it also on Minerva, changing line 5070 to read

Code: Select all

EW pipep;"ram1_eval_in_bas>"
but this stops at 5070 with a 'channel not open' error...

Later,
Jan


Post Reply