Author Topic: Dynamic Goto  (Read 703 times)

0 Members and 1 Guest are viewing this topic.

Offline asertus

  • CPC664
  • ***
  • Posts: 133
  • Country: es
    • Awards
Dynamic Goto
« 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...



« Last Edit: 09:54, 17 September 21 by asertus »
like
0
No reactions

Online eto

  • Supporter
  • 6128 Plus
  • *
  • Posts: 507
  • Country: de
    • Awards
Re: Dynamic Goto
« Reply #1 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_...
like
0
No reactions

Offline pelrun

  • Supporter
  • 6128 Plus
  • *
  • Posts: 809
  • Country: au
    • index.php?action=treasury
    • Awards
Re: Dynamic Goto
« Reply #2 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.
like
0
No reactions

Offline Gryzor

  • Administrator
  • 6128 Plus
  • *****
  • Posts: 17.181
  • Country: gr
  • CPC-Wiki maintainer
    • CPCWiki
    • Awards
Re: Dynamic Goto
« Reply #3 on: 11:47, 17 September 21 »
You would think that RENUM would parse the listing and change the references?
like
0
No reactions

Online eto

  • Supporter
  • 6128 Plus
  • *
  • Posts: 507
  • Country: de
    • Awards
Re: Dynamic Goto
« Reply #4 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.

like
0
No reactions

Offline Gryzor

  • Administrator
  • 6128 Plus
  • *****
  • Posts: 17.181
  • Country: gr
  • CPC-Wiki maintainer
    • CPCWiki
    • Awards
Re: Dynamic Goto
« Reply #5 on: 12:04, 17 September 21 »
Oh I know, been there. It looked like magic! But the problem exists.
like
0
No reactions

Online eto

  • Supporter
  • 6128 Plus
  • *
  • Posts: 507
  • Country: de
    • Awards
Re: Dynamic Goto
« Reply #6 on: 12:32, 17 September 21 »
Oh I know, been there. It looked like magic! But the problem exists.


which problem?

like
0
No reactions

Offline ChaRleyTroniC

  • CPC464
  • **
  • Posts: 31
    • Awards
Re: Dynamic Goto
« Reply #7 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.
like
0
No reactions

Offline SRS

  • Supporter
  • 6128 Plus
  • *
  • Posts: 657
  • Country: de
  • Schneider CPC464 - what else ?
    • Awards
Re: Dynamic Goto
« Reply #8 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

like
0
No reactions