Page 1 of 1

SuperBASIC Functions (RETurn value type)

Posted: Tue Jun 30, 2020 12:41 am
by ql_freak
I'm still working on the cc compiler driver for EJC and have now found the problem, why the error messages from Pass 1 of the Lattice compiler are not output (neither to screen, nor to the redirection file). Short descriptions of the problem for experts only: Lattice C has NOT any knowledge about the default directories of SuperToolkit II (I still own a letter to me from Anthony).

Thereby I realized, that I can write support functions in SB, which helps compiling.

I ALWAYS QUOTE FILENAMES ON QDOS (highly recommended!). So to start the EJC compiler driver I use e.g.:

ex'cc',#1;'cc hello' /* You MUST NOT give the full name as in C68! */

It's nervous to quote 'cc' after the ex. Ah' easy in SuperBASIC:

cc = 'CC':REMark That is not possible LUCKILY(!), in Python such kind of things are
REMark: possible, and it's often THE HORROR

But SuperBASIC differs(!), it's also a command language for QDOS (which Python is currently NOT - note, it would be possible to make it to one of the BEST shells). So in SuperBASIC it would be nice (ONLY FOR DIRECT COMMANDS!), if you could use the above assignement and then just use:

ex cc,#1...

WITHOUT making the SuperBASIC name "cc"(!).

Well, I have detected in QPC2:

1234 :
1235 DEFine FuNction cc:return 'cc':END DEFine
1236 :
10000 ex cc;'xyz hello' /* One pair of " ' " less :-) */

Which operating system/BASIC versions do support this. A BBQL does NOT(!). I have tested this today: BBQL will not allow you to enter line 1235 (you must use the name cc$).

Does Minerva support this, or is this special to SBasic?

YES, I know, now the SB name cc is also defined (a function), but now it's explicit, and SuperBASIC will give me an error, if I e.g. will try:

cc = 'Currently Confused':REMark Error: assignement can only be to a variable or array element

--
BBQL: "Bare Bone QL", e.g. an original QL (at least with original mainboard).

Re: SuperBASIC Functions (RETurn value type)

Posted: Wed Jul 01, 2020 11:29 pm
by janbredenbeek
ql_freak wrote:Well, I have detected in QPC2:

1234 :
1235 DEFine FuNction cc:return 'cc':END DEFine
1236 :
10000 ex cc;'xyz hello' /* One pair of " ' " less :-) */

Which operating system/BASIC versions do support this. A BBQL does NOT(!). I have tested this today: BBQL will not allow you to enter line 1235 (you must use the name cc$).

Does Minerva support this, or is this special to SBasic?

Minerva gave an error at the RETurn statement. Obviously it tries to convert the string value to a numeric value, which fails since it is not a valid number.

But you might be able to do it with a machinecode function. On return, a machinecode function should specify the type of the value returned in D4 (1 for string, 2 for FP and 3 for integer). This is different from Basic functions, whose type is determined by the name (except perhaps for QPC2's SBASIC).
It shouldn't be very difficult to write (just reserve space on the Math stack, put the string on it and return with D4=1).

Jan

Re: SuperBASIC Functions (RETurn value type)

Posted: Fri Jul 03, 2020 12:59 am
by ql_freak
Thank you Jan! I have known, that it's possible with Machine code functions. But this is a bit uncomfortable. But as I'm normally using QPC2, that's no problem.