128 Basic and keywords within quotes

Post Reply
SabreWulf
Posts: 19
Joined: Mon Jul 26, 2021 6:31 pm

128 Basic and keywords within quotes

Post 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.
SabreWulf
Posts: 19
Joined: Mon Jul 26, 2021 6:31 pm

Re: 128 Basic and keywords within quotes

Post by SabreWulf »

Double post deleted.
Last edited by SabreWulf on Fri Mar 10, 2023 3:32 pm, edited 1 time in total.
SabreWulf
Posts: 19
Joined: Mon Jul 26, 2021 6:31 pm

Re: 128 Basic and keywords within quotes

Post 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.
User avatar
1024MAK
Posts: 5183
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...

Re: 128 Basic and keywords within quotes

Post by 1024MAK »

Hmm, I thought this subject sounded familiar, see also here.

Mark
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Amp

:!: Standby alert :!:
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :!:
Looking forward to summer being good this year.
SabreWulf
Posts: 19
Joined: Mon Jul 26, 2021 6:31 pm

Re: 128 Basic and keywords within quotes

Post 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.
User avatar
1024MAK
Posts: 5183
Joined: Mon Sep 26, 2011 10:56 am
Location: Looking forward to summer in Somerset, UK...

Re: 128 Basic and keywords within quotes

Post 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
ZX81 Variations
ZX81 Chip Pin-outs
ZX81 Video Transistor Amp

:!: Standby alert :!:
There are four lights!
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :!:
Looking forward to summer being good this year.
SabreWulf
Posts: 19
Joined: Mon Jul 26, 2021 6:31 pm

Re: 128 Basic and keywords within quotes

Post by SabreWulf »

Thanks Mark.
Post Reply