Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I'm getting an error with my SLEEP() function in commodore BASIC

I've been recently learning commodore 64 BASIC and I'm trying to create a text adventure game. I'm getting an error concerning all of the sleep functions I used.
My code is:

10 PRINT "WELCOME TO THE SURVEY"
20 SLEEP(1000)
30 PRINT CLS
40 INPUT "START SURVEY?" ANSWER$
50 IF ANSWER$ == "YES"
60 PRINT CLS
70 PRINT "YOU BEGIN THE SURVER"
80 SLEEP(1000)
90 ELSE
100 SLEEP(1000)
110 PRINT CLS
120 PRINT "COME BACK ANOTHER TIME"
130 SLEEP(1000)
140 PRINT CLS
150 GOTO 10

The error is:

ARRAY AT LINE 20

Any ideas on how to fix this?

like image 994
TurnipYossarian Avatar asked Nov 01 '25 08:11

TurnipYossarian


1 Answers

If your C64 doesn't have a version of BASIC greater than or equal to 7.0, SLEEP is not a C64 instruction.

When your code is executed the interpreter recognizes SLEEP as an undimensioned array (because you used SLEEP() with the parenthesis) and therefore returns an error.
And if the statement does exist you would have to use:

10 SLEEP 60

If the SLEEP statement is not present, you should write some subroutine (to be called with the GOSUB statement) that does a delay.

C64 Manual

Reading the appendix of the manual I saw that there is a WAIT statement, but to use such statement you should find some memory location updated by the C64 every clock (there should be, but I can't remember which one it is).

I have also found an answer here on Stackoverflow related to delay for VIC20/C64. It might be a good solution: How to wait x seconds in 6502 basic

like image 104
SJB Avatar answered Nov 03 '25 04:11

SJB



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!