home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.sys.cbm      Discussion about Commodore micros      53,866 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 53,651 of 53,866   
   K-Guide to Kp@3:770/3.0   
   Re: Messing around, creating a disk edit   
   07 Jun 23 11:03:00   
   
   From: nospam.K-Guide@f230.n130.z1.fidonet.org   
      
   On Tue  6-Jun-2023  4:55p, Kp Kp@3:770/3.0 wrote:   
   KK> I need some scrutinizing  on my crappy coding expertise. Haven't made a   
   KK> program in years.. Could be junk or have no idea what I am doing.   
   KK> Gibberish? Lol.   
      
   KK> 10 PRINT "***** C64 DISK EDITOR *****"   
   KK> 20 PRINT   
   KK> 30 INPUT "Enter the name of the disk file: "; FILENAME$   
   KK> 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.   
      
   KK> 130 IF CHOICE = 1 THEN   
   KK> 140   INPUT "Enter the sector number to display: "; SECTOR   
   KK> 150   PRINT   
   KK> 160   SYS 64738   
   KK> 170   PRINT   
   KK> 180   GOTO 50   
   KK> 190 ELSEIF CHOICE = 2 THEN   
   KK> 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  THEN  [:ELSE ]   
      
   They all must be contained on the same line!   
      
   Once the THEN  are run OR the ELSE  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   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca