? Problems while trying to make a LOAD/EXEC function on my DOS-like program. (Page 1) ● SmileBASIC Source Forums

Sign In

Register
*Usernames are case-sensitive
Forgot my password

Migrating to a new website for SmileBASIC 4

Problems while trying to make a LOAD/EXEC function on my DOS-like program.

  • #1 ✎ 434 the_squat1115 First Year My account is over 1 year old Website Forum Contributor Hidden Achievements Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Hi, its been a while since I don't make new forums because of problems while debugging on SmileBASIC. Its giving me a syntax error on line 38 of my program (after using the "EXEC" command and specifying what file and what type of file to load, it checks if it exists.), however, the program appears to refuse to check if the file exists or its not corrupted. This is my code: IF CHKFILE(PROGRAM$)==TRUE THEN EXEC "PRG1:",PROGRAM$ ELSE PRINT "File not found... Please check if specified file exists or check if it isnt corrupted.":GOTO @MAIN Notes: The variable PROGRAM$ is supposed to store the specified program to load. I'm actually not sure if the variable should go with the semicolon before it. Posted Edited by the_squat1115
  • #2 ✎ 349 CyberYoshi64 Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Second Year My account is over 2 years old Website Night Person I like the quiet night and sleep late. Express Yourself The PROGRAM$ should be added to the "PRG1:" with a +. IF CHKFILE(PROGRAM$)==TRUE THEN EXEC "PRG1:"+PROGRAM$ ELSE PRINT "File not found... Please check if specified file exists or check if it isnt corrupted.":GOTO @MAIN You should also do other checks, such as PROGRAM$'s length being between 1 and 14 (or 32 if used in SB4) and that it contains valid chars to prevent further crashes: IF LEN(PROGRAM$)<1 || LEN(PROGRAM$)>14 THEN ?"Invalid program name length." ENDIF FLAG=0 FOR I=0 TO LEN(PROGRAM$)-1 IF INSTR("[email protected]_-.ABCDEFGHIJKLMNOPQRSTUVWXYZ",PROGRAM$[I])==-1 THEN FLAG=1BREAK NEXT I IF FLAG THEN ?"Did you mistype the name or did you type in lowercase?":GOTO @MAIN EDIT: Made a bit clearer... Posted Edited by CyberYoshi64