Page 1 of 1

CONT or CONTINUE in BASIC programs

Posted: Wed Jun 22, 2022 2:53 am
by MOB-i-L
Is there any use for CONT (or CONTINUE for ZX Spectrum) inside a BASIC program?

CONT inside programs works different in e.g. ZX81/ZX Spectrum vs VIC20/C64.

I know that CONT is useful on the command line.

CONT
Suppose p/q was the last report with a non-zero. Then CONT has
the effect GOTO q if p <> 9, GOTO q+1 if p = 9 (STOP statement)
(Vickers 1981)

Re: CONT or CONTINUE in BASIC programs

Posted: Wed Jun 22, 2022 9:31 am
by XavSnap
Hi MOB-i-L,

The CONT can't be used to store machine code, but can be followed by a zero bloc.

CONT in a programme is like a REM
CONT don't use the NXT_LINE BASIC variable.
CONT don't use the ADD_CHAR variable.
I tried to use CONT to jump to a line, but i haven't found the good process.

It should retrieve the last stack used in the BASIC ROM, but it can't be use with the BASIC monitor...

Re: CONT or CONTINUE in BASIC programs

Posted: Wed Jun 22, 2022 7:47 pm
by MOB-i-L
CONT in a programme is like a REM
I don't agree to that because CONT is like GOTO last executed line unless STOP because then GOTO last executed line +1.
In this program you RUN and then press CONT and then SPACE/BREAK key, then CONT again and BREAK etc. You can also try RUN 75 and then press CONT for an infinite loop.

Code: Select all

   5 STOP 
  10 PRINT "1";
  20 PRINT "2";
  30 PRINT "3";
  40 PRINT "4";
  50 PRINT "5";
  60 PRINT "6";
  70 CONT 
  75 STOP 
  80 CONT 
 100 FOR I=1 TO 24
 110 SCROLL 
 120 NEXT I
 130 SAVE "DICE"
 140 RUN
The program was saved using RUN 100, since that should make the .p file smaller.

Re: CONT or CONTINUE in BASIC programs

Posted: Thu Jun 23, 2022 9:20 am
by XavSnap
Hi MOB-i-L,

Yes, it's a weird behavior...
It loops to the last error or break point.

Or...

Code: Select all

  1 POKE 16384,08
  2 POKE 16391,20
  10 PRINT "1";
  20 PRINT "2";
  30 PRINT "3";
  40 PRINT "4";
  50 PRINT "5";
  60 PRINT "6";
  70 CONT 

Code: Select all

  10 PRINT "1";
  20 PRINT "2";
  25 POKE 16384,8
  30 PRINT "3";
  40 PRINT "4";
  50 PRINT "5";
  60 PRINT "6";
  80 CONT 
Loop drived with the ERR_SP value...

Re: CONT or CONTINUE in BASIC programs

Posted: Mon Sep 05, 2022 11:38 pm
by TMD2003
If anyone's still interested, this is something I asked towards the end of last year's CSSCGC, and Andy Jenkinson came up with the goods.

High/Low Continue showed how CONTINUE, in combination with poking a couple of system variables, can be used to jump to a specific statement in a multi-statement line on the Spectrum. Andy's program made sure that the entire "game" was packed into a single line of BASIC with a double-digit number of colons.

This obviously limits its use on the ZX81, but I wrote my own conversion of the program anyway, so that poking the one required system variable followed by CONTINUE will execute a GOTO, in a rather roundabout way.