Jump to content
IGNORED

Pirate ship for Commodore Pet 2001


Frozone212

Recommended Posts

It's real short and too easy but Fun to program for. Commodore basic does not support the ELSE statement. Therefore, I am somewhat screwed with decision making so the majority of commands done through INPUT. Bad practice but AFAIK, there is no extension that adds the command, I could be wrong here. I hope to expand this down the road.

 

Enjoy

Pirate Ship.d64

  • Like 1
Link to comment
Share on other sites

On 12/1/2022 at 4:51 PM, Frozone212 said:

Commodore basic does not support the ELSE statement. Therefore, I am somewhat screwed with decision making

 

While it's a little more complex, you can use GOTO to implement IF/ELSE logic.

 

image.thumb.jpeg.272e649e3f9cce19466d878aa7f899f9.jpeg

 

To cover multiple lines do this:

 

10 if 2 < 1 then goto 60
20 rem this is start of ELSE logic
30 print "in the ELSE block"
40 print "still in ELSE block
50 goto 90
60 rem this is start of IF TRUE logic
70 print "in the IF block"
80 print "still in IF block"
90 rem endif

 

  • Like 1
Link to comment
Share on other sites

You can sometimes use ON .. GOTO to simulate IF/THEN/ELSE:

 

10 IF A$="THIS" THEN 20 ELSE 30

 

Becomes:

 

10 ON (A$="THIS")+2 GOTO 20,30

 

This relies on the fact that if A$="THIS" is true, it is assigned the value -1 (except on Applesoft, where it is assigned the value 1), and if A$="THIS" is false, it is assigned the value 0.  Adding 2 to the result makes it 1 for the true result, and 2 for the false result.  You'll need to add a GOTO or something to skip around the code for the false result (so the true result doesn't fall through to the false result).

 

You can also do this with GOSUB:

10 ON (A$="THIS")+2 GOSUB 20,30
11 STOP:REM OR GOTO SOMEWHERE ELSE
20 PRINT "TRUE":RETURN
30 PRINT "FALSE":RETURN

 

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...