Printing a board in Commodore Basic 4.0?
Asked Answered
A

3

12

I'm having trouble with printing a board of dots in Commodore Basic 6502.

This is what I have to far: (it's a subroutine)

10 INPUT "Please enter a number:", X
20 DIM A$(X, X)
30 FOR I = 0 TO X
40 FOR J = 0 TO X
50 A$(I, J) = "."
60 NEXT
70 NEXT
80 PRINT A$
END

Can anyone help me out with it because when I paste it into the emulator, type END, and press enter literally nothing happens?

Any help is much appreciated. I'm trying to build a word search game.

Australian answered 19/3, 2014 at 22:41 Comment(8)
I'm upvoting this question simply because it's so old school.Tanny
Also, gonna take a wild guess that you can't print an array. You probably have to print each element within the array.Tanny
Is this a real machine? Pet, Vic-20, C-64? Or a simulator?Squirt
You need to type RUN and hit enter to get it to go. There are also some other problems as folks have noted, and, from deepest darkest corners of my memory, I think arrays are 1-based, not 0-based.Megargee
why on earth was this downvoted? Just getting this far is plus worthy enough. Curious as to why you would be programming it at allGobbledegook
OK, so it appears I was wrong about the 1-based arrays :)Megargee
this is an emulator; C-64 with basic 4.0Australian
@Suraya if you are talking about Basic 4.0 this machine must be one of the PET/CMB models. C64 was shipped with Basic 2.0Jeep
M
9

Just for laughs, here is some code that does what I think you want to do:

C64 screen shot

Just type RUN and hit enter!

Megargee answered 19/3, 2014 at 23:30 Comment(2)
Sorry to ask, but did you type in the code as well?Megargee
Got it; for some reason I had to put everything in lowercase...odd. Appreciate your help!Australian
S
0

Snip to fill an array with dots and print it:

10 INPUT "Please enter a number:", X
20 DIM A$(X, X)
21 REM make the array
30 FOR I = 0 TO X
    40 FOR J = 0 TO X
        50 A$(I, J) = "."
    60 NEXT
70 NEXT
80 REM print the array
90 FOR I = 0 TO X
    91 FOR J = 0 TO X
        92 PRINT A$(I, J);
    93 NEXT
    94 PRINT
95 NEXT
99 END
Stork answered 23/8, 2016 at 3:49 Comment(0)
A
0

you don't have to instantiate the array A$:

10 rows=12
20 cols=10
30 gosub 1000
40 end
50 :
1000 for i=1 to rows
1010   for j=1 to cols
1020     print ".";
1030   next
1040   print
1060 next

run
Abreaction answered 1/12, 2023 at 12:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.