CPCWiki forum

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

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

Title: Re: Dynamic Goto
Post by: Gryzor on 10: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 10:32, 17 September 21
Quote from: Gryzor on 10:04, 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 16: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 21:00, 21 September 21
at least for EVAL there was i.e. XBASIC from 1986: https://cpcrulez.fr/applications_coding-xbasic_AI.htm

Powered by SMFPacks Menu Editor Mod