Page 2 of 2
Re: VAL function in SuperBasic
Posted: Wed Mar 22, 2017 12:44 am
by janbredenbeek
ql_freak wrote:I also have renamed the function, cause it is no BASIC VAL() function. Look what VAL in Visual BASIC, C64 BASIC, ... does. The Spectrum VAL() function is special. So I choosed the name EVAL(expr$,error_result$). This is the same function name as in Python (which also has such a nice function). BTW: A normal BASIC compatible VAL() function (not Spectrum VAL) would be useful too.
Just wait a few days and I will post BASICODE on GitHub, which includes most functions which are in M$ BASIC but not in SuperBASIC. This includes LEFT$, MID$, RIGHT$ and VAL. I wrote them as machinecode functions so that BASICODE programs (which are mostly based on M$ BASIC but use subroutines for machine-specific commands like CLS etc) could be run on the QL. These programs were distributed over the radio in the '80s but there's an
archive now on GitHub containing hundreds of programs - mostly in Dutch though but also in German since it was popular in the former GDR too.
I've updated my code from 1987 so it's compatible now with SMSQ/E and SBASIC - only need to clean things up a bit and write documentation (well there is, but in Dutch

). It was originally released on EPROM with a cassette interface, but still allows loading programs from ASCII files so you don't need cassettes now
Jan.
Re: VAL function in SuperBasic
Posted: Thu Mar 23, 2017 5:41 pm
by ql_freak
janbredenbeek wrote:It was originally released on EPROM with a cassette interface, but still allows loading programs from ASCII files so you don't need cassettes now :D
Wow, there was a cassette interface for the QL, I have never heard from one. What formats can it read? Is there SuperTape (from the German c't magazine) available? It was available for most computers (Spectrum, C64, Dragon, ...), much faster than the inbuilt cassette software and was therefore often used to transfer programs from one system to another. I have some cassettes with BASIC programs from my first "computer", a Sharp Pocket PC-1500. And as far as I can remember, I have a SuperTape implementation for it.
Do you have any circuit diagramms for the cassette interface?
Re: VAL function in SuperBasic
Posted: Thu Mar 23, 2017 6:49 pm
by ql_freak
ql_freak wrote:stevepoole wrote:Hi,
EmmBee's program works well on my SGC QL, but not under SMSQ, nor therefore with QPC2, as stated.
It worked here on my QPC2, but the problem is, that it doesn't return an error, if there is an "error in expression". In addition it does not work with MultiBASIC jobs.
So I have improved the program. It is now compatible with MultiBASIC and it needs a second string parameter, which must be a string variable, as it is assigned an error message, so that you can test afterwards if there was an error. If there was no error (a correct expression was passed in the first parameter) this variable is set to the empty string ("").
I also have renamed the function, cause it is no BASIC VAL() function. Look what VAL in Visual BASIC, C64 BASIC, ... does. The Spectrum VAL() function is special. So I choosed the name EVAL(expr$,error_result$). This is the same function name as in Python (which also has such a nice function). BTW: A normal BASIC compatible VAL() function (not Spectrum VAL) would be useful too.
Here is the code together with a simple test program, Turbo Toolkit Version 3.40 or higher(!) and SuperToolkit II is required (edited 2017 Mar 23: added po% and pi% to LOCAL statement in 32130):
Code: Select all
100 REMark Test for EVAL(string$,error_result$) SuperBASIC function
110 :
120 a$="10":rorre$="":REMark default no error
130 a=EVAL("3*4+a$",rorre$)
140 IF (rorre$ <> "")
150 PRINT rorre$
160 ELSE
170 PRINT a
180 END IF
30000 :
32100 REMark Support PROCedures AND FuNctions
32110 :
32120 DEFine FuNction EVAL(x$,err$)
32130 LOCal result,test$,po%,pi%
32140 err$="":pi%=FOPEN("CON")
32150 po%=FOPEN("CON"):CLOSE#po%:CLOSE#pi%
32160 IF FOP_NEW(#po%,"PIPE_1024"):err$="Cannot open PIPE":RETurn 0
32170 CONNECT po% TO pi%
32180 result = 0
32190 test$="PRINT#po%,"&x$
32210 IF x$ <> FILL$(" ",LEN(x$))
32220 COMMAND_LINE JOBID()
32260 TYPE_IN test$&CHR$(10)
32270 TYPE_IN FILL$(CHR$(194),LEN(test$))&"CONTINUE"&CHR$(10):STOP
32280 CLOSE#po%:IF EOF(#pi%):CLOSE#pi%:err$="Error in expression":RETurn 0
32290 CLOSE#pi%
32300 TYPE_IN "result = " & x$ & CHR$(10)
32340 TYPE_IN "CONTINUE" & CHR$(10)
32380 STOP
32420 END IF
32460 RETurn result
32500 END DEFine EVAL
Re: VAL function in SuperBasic
Posted: Thu Mar 23, 2017 11:22 pm
by janbredenbeek
ql_freak wrote:
Wow, there was a cassette interface for the QL, I have never heard from one. What formats can it read? Is there SuperTape (from the German c't magazine) available? It was available for most computers (Spectrum, C64, Dragon, ...), much faster than the inbuilt cassette software and was therefore often used to transfer programs from one system to another. I have some cassettes with BASIC programs from my first "computer", a Sharp Pocket PC-1500. And as far as I can remember, I have a SuperTape implementation for it.
Well it is not very fast, 1200 baud. But there's an easy way to retrieve data from .wav files created from audio cassettes using minimodem under Linux. It's described in the English wikipedia article about Basicode:
https://en.wikipedia.org/wiki/BASICODE.
Do you have any circuit diagramms for the cassette interface?
Here it is:
It uses a 4,5V battery to pull-up the input voltage to the NET interface to just around the point where the input bit flips from 0 to 1 - of course you can use any DC source available. The Dutch QL User group even made PCB's containing this interface which fitted into the QL's expansion port on the back, including the EPROM containing the software. This contained the BASICODE translator but also commands CLOAD and CSAVE for loading and saving files to cassette - a slow but cheap means of archiving files when floppydisks were still expensive.
Jan
Re: VAL function in SuperBasic
Posted: Fri Mar 24, 2017 3:22 am
by ql_freak
Thank You Jan!
Albeit I'm afraid I cannot investigate much time in this interesting project in the near future, as I have now finally found a LG G5 smartphone for a reasonable price :-) I'll hope I will get it tomorrow :-)
My smartphone (LG Optimus 4x HD) is unfortunately no more working correctly (e. g. GPS doesn't work reliably). And I want a phone with a removable battery (the G5 is the last "premium phone", which supports it).
So I will most probably be not so often here, because I have to configure my new smartphone.
It all would be easier, if Symbian (aka EPOC, aka Psion Pocket computers) still were the leading smartphone platform.
I love Symbian/EPOC (I own a Psion 5mx Pro and a Nokia Communicator E90), which both are much better than any Android phone. Unfortunately both are now "outdated" (e. g. the available browsers are no more capable of reading sites in a reasonable time).
QL, Psion, Symbian, Nokia forever!