Page 1 of 1

128 Basic and keywords within quotes

Posted: Fri Mar 10, 2023 3:05 pm
by SabreWulf
Example:
10 LET z$="10101010"
20 PRINT VAL ("BIN "+z$)

In 48 basic, the BIN is enter-able as a keyword. I can't see a way for 128 basic to recognise BIN within quotes as anything other than "B" + "I" + "N". The result in 128 basic is the equivalent of typing 'B' 'I' 'N' in 48 basic: i.e. variable not found; rather than evaluating BIN z$.

Unsurprisingly, writing it in 128 basic and transferring the listing to 48 basic with 'spectrum' retains the 'B' 'I' 'N' as three separate characters - rather than then tokenising it.

Is there any way of entering line 20 in 128 basic and it working as intended? I can see that the single character entry wouldn't be able to parse it as a keyword if it can't be made aware that it's a keyword.

Re: 128 Basic and keywords within quotes

Posted: Fri Mar 10, 2023 3:30 pm
by SabreWulf
Double post deleted.

Re: 128 Basic and keywords within quotes

Posted: Fri Mar 10, 2023 3:32 pm
by SabreWulf
Answering my own question, a solution is:

20 PRINT VAL (CHR$ 196 + z$)

To save anyone looking that up, CHR$ 196 is, unsurprisingly, the BIN keyword.

I hadn't realised that 128 basic parsing would require workarounds like this. Anyway, onward and upward.

Any other solutions would still be appreciated.

Re: 128 Basic and keywords within quotes

Posted: Tue Mar 21, 2023 6:37 am
by 1024MAK
Hmm, I thought this subject sounded familiar, see also here.

Mark

Re: 128 Basic and keywords within quotes

Posted: Tue Apr 11, 2023 8:31 pm
by SabreWulf
There was a curious but impractical answer there.

Perhaps I should have been more succinct: "Was the 128 editor developed without considering that 48k Spectrum BASIC usefully allows tokenised keywords within quotes? Is the only practical way around the parsing to replace the keyword with CHR$(n) as I've already stated?"

All of my Spectrum BASIC programming since 1982 has been on the 48 - the 128 has sat on the shelf for years as it has the infernal Plus keyboard. The discovery of a limitation and difference in the 128 editor surprised me at first, but it became obvious that the parser and user would need a way of distinguising keywords in quotes. I was attempting to ask if that was a thing.

Hence, a post here. I've only recently become aware of Spectrumcomputing and thought that it was a completely separate site.

Re: 128 Basic and keywords within quotes

Posted: Tue Apr 11, 2023 11:26 pm
by 1024MAK
There are three English speaking forums that cover the ZX Spectrum. Here, Spectrum Computing and World of Spectrum. I pop up on all three…

There is also World of Spectrum Classic, but that does not have a forum.

And just to be clear, all these sites are all completely separate and independent of one another (and indeed they are rivals).

128K BASIC has quite a lot of bugs and design limitations. Not being able to use tokenised keywords as you describe is unlikely to have been anywhere near the top of the list of priorities.

Also of interest may be the “Gosh Wonderful BASIC” ROM. See this site. This also has a character by character input system rather than a keyword entry system. But it also does not tokenise BASIC keywords within quotes.

Mark

Re: 128 Basic and keywords within quotes

Posted: Wed Apr 12, 2023 11:20 am
by SabreWulf
Thanks Mark.