News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_asertus

Dynamic Goto

Started by asertus, 07:53, 17 September 21

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

asertus

Hi, I have just read some tweets about Sir Sinclair, RIP. And one caught my attention.


It was about a publication about ZX80 and some basic code. It seems that computer could have dynamic gotos


That is, GOTO variable .


It is not possible in Locomotive Basic, I have tried and just got syntax error, or is it possible somehow in Amstrad basic to do it? Just a curiosity.


In the image, lines 110, 121, etc...



eto


In Locomotive Basic there is a much more robust solution for this:
"ON x GOTO" and "ON x GOSUB"

https://www.cpcwiki.eu/index.php/Locomotive_BASIC#ON_variable_GOTO_ln_x1.2C_x2.2C_x3.2C_x4.2C_...

pelrun

Yeah, the first time you did a RENUM all your calculations would be wrong. ON x GOTO automatically adjusts the destination list to keep pointing at the right places.

Gryzor

You would think that RENUM would parse the listing and change the references?

eto

Quote from: Gryzor on 09:47, 17 September 21
You would think that RENUM would parse the listing and change the references?


RENUM was such a huge help when you had to squeeze in new code in between existing lines. I used it just last year heavily in my game to "organise" the different code areas in a way so I better remember at which line what part starts. Works like a charm even with 30KB of Basic code.


Gryzor

Oh I know, been there. It looked like magic! But the problem exists.

eto

Quote from: Gryzor on 10:04, 17 September 21
Oh I know, been there. It looked like magic! But the problem exists.


which problem?


ChaRleyTroniC

I remember computed GOTO being one of the two features from other BASICs I most missed in Locomotive BASIC - that and EVAL. I managed to hack EVAL in somehow, but not computed GOTO.

SRS


Powered by SMFPacks Menu Editor Mod