CPCWiki forum

General Category => Programming => Topic started by: asertus on 09:53, 17 September 21

Title: Dynamic Goto
Post by: asertus on 09:53, 17 September 21
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...


Title: Re: Dynamic Goto
Post by: eto on 10:12, 17 September 21

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_...
Title: Re: Dynamic Goto
Post by: pelrun on 10:15, 17 September 21
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.
Title: Re: Dynamic Goto
Post by: Gryzor on 11:47, 17 September 21
You would think that RENUM would parse the listing and change the references?
Title: Re: Dynamic Goto
Post by: eto on 12:01, 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.

Title: Re: Dynamic Goto
Post by: Gryzor on 12:04, 17 September 21
Oh I know, been there. It looked like magic! But the problem exists.
Title: Re: Dynamic Goto
Post by: eto on 12:32, 17 September 21
Oh I know, been there. It looked like magic! But the problem exists.


which problem?

Title: Re: Dynamic Goto
Post by: ChaRleyTroniC on 18:50, 17 September 21
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.
Title: Re: Dynamic Goto
Post by: SRS on 23:00, 21 September 21
at least for EVAL there was i.e. XBASIC from 1986: https://cpcrulez.fr/applications_coding-xbasic_AI.htm