Useful Subroutines for BASIC Programming
Here are some subroutines I made for my BASIC programs (that’s code for you young-uns).
change UPPERCASE to lowercase
This is for the old Apple][ BASIC I am using to code on, but it should work for most retro computers.
characters , : ” are invalid
starts with qq$ & outputs q$
BASIC code
100 q$=””
105 for x= 1 to len(qq$)
110 z= asc(mid$(qq$,x,1))
115 if z < 65 or z > 90 then x$ = chr$(z)
120 if z > 64 and z < 91 then x$ = chr$(z+32)
125 q$= q$ + x$
130 next x
assign numbers to x/y coordinates in a grid
starts with GMax – the number of columns or rows in the grid (square only)
adds linear numbers to the array: GR(y,x)
I use Y/X instead of X/Y because I am counting rooms from top to bottom.

BASIC code
100 dim gr (gm,gm)
105 z=1
110 for y = 1 to gm
115 for x= 1 to gm
120 GRid (y,x)= z
125 z= z+1
130 next x : next y
center text on the screen
starts with q$ (text) & w (monitor character width)
prints q$ (centered)
BASIC code
htab int(w – len(q$))/2 : print q$
Thank you for stopping by.
home | my recipes | my photos | I’m high
