From Newsgroup: comp.sys.cbm
On Tue 6-Jun-2023 4:55p, Kp Kp@3:770/3.0 wrote:
I need some scrutinizing on my crappy coding expertise. Haven't made a program in years.. Could be junk or have no idea what I am doing. Gibberish? Lol.
10 PRINT "***** C64 DISK EDITOR *****"
20 PRINT
30 INPUT "Enter the name of the disk file: "; FILENAME$
40 PRINT
First and foremost, I am not an expert in C64/128 programming, I am just drawing from the cob-web infested parts of my brain here... So here are my thoughts.
The C64 and 128 have dual character sets (UPPER/Gfx vs (Upper/Lower) and based on the above it appears your in Upper/lower. When in this mode commands like PRINT, INPUT, OPEN, AND Varables all need to be in lowercase.
Also filename$ is too long. Varables on C64 & 128 can be up to two characters + a designator. They must start with a letter then you can have a letter, number, or designator. Haveing the $ at the end is fine as it tells the computer its a string. Use % for integers if you want to pick up a cycle or two. There are also designatores for single or double percision floating varables too.
130 IF CHOICE = 1 THEN
140 INPUT "Enter the sector number to display: "; SECTOR
150 PRINT
160 SYS 64738
170 PRINT
180 GOTO 50
190 ELSEIF CHOICE = 2 THEN
200 INPUT "Enter the sector number to edit: "; SECTOR
The C64 nor C128 support this type of statement structure. The Syntex for IF statements are:
IF <expression> THEN <statements> [:ELSE <statements>]
They all must be contained on the same line!
Once the THEN <statements> are run OR the ELSE <statements> are run the program
will drop to the following line of code. This is why C64 & C128 has alot of spegitty code in their basic files, but with the use of GOSUB and GOTO carefully you can limit that to a point. If you make your program where its more of a Hub and Spoke design, it will be easier to follow then all kinds GOTO
statement to jump over blockes of code. Something like this psudocode
Main
Print Banner
Get Filename and store in fn$
M1: GOSUB Display Menu (put user input into m)
ONGOSUB m C1, C2, C3, etc...
GOTO A:
C1: Statements for Menu #1
return
01: Any routinmes for C1
02: etc...
C2: Statements for Menu #2
03: Any routines for C2
04: etc...
This is much easier to follow. Like everything there is a balance here, so if you can handle it with just 3-5 lines of code in a block then no need for a routine. When it gets beyond that is when I start thinking about making a routine out of it.
Also your line numbers can be from 0 - 65535 so give each routine a wide number
range. Like MAIN = 100-500, Display Menu = 600-1000, etc... This way when you
need to change things in the rotines your not suck. Once its finished use a renumber utility to restructure them with lower numbers and give youself a 100 line gap between sections. Just how I like to do things.
Also I would move the OPEN statement in line 50 into the routines that need it.
This way its only opened and closed when needed. I know its a bit more code, but make for easier to follow code.
This along with the other posters comments you should have a good start. I would suggest you snag a copy of the C128 System Guide or the C64 Systems Guide
they do a great job of laying out the syntex and rules plus the back is setup more as a referance for all the commands, so its easy to look stuff up. It should get you up to speed, or dare I say down to C64/128 Basic.
Hope this helps....
[+] K-Guide
--- Synchronet 3.20a-Linux NewsLink 1.114