Modularity with plain SuperBasic
Posted: Tue Mar 19, 2024 4:42 pm
To complement this post viewtopic.php?t=4287&start=16, I decided to open this new thread to discuss some updates of my methods to program plain SuperBasic without line numbers. Basing the new developments on the same example of my modular generic BOOT with only these two small numbered files :
The BOOT file has one PROcedure called BYE and one FuNtion called ALN (Add_Line_Numbers).
After loading these, BOOT will immediately execute two commands (statements without line numbers) : a call to ALN to add line numbers to a file called mdv1_MANIFEST_txt that will output a file called mdv1_MANIFEST_bas and MRUN (Merge and Run) it.
This is my first idea of the MANIFEST file mdv1_MANIFEST_txt :
The statements of MANIFEST (all with line numbers outside PROCedure or FuNction) will execute and add line numbers to five files : TOP_MENU PSION_MENU LANG_MENU C68_MENU and CFORMS, and after that, MERGE them to the BOOT program.
Finally, one numbered statement outside PROcedure or FuNction :
will be executed, deleting the MANIFEST statements no longer useful (In fact, this statement has been automatically relocated at line 32701 and statement 32741 was overwritten).
Code: Select all
DEV$="FLP1_" : MODE 4 : PROG_USE DEV$ : DATA_USE DEV$
32741 MRUN mdv1_TOOB
32742 DEFine FuNction aln(f$,f,d)
32743 input_file$ = dev$ & f$ & "_txt"
32744 output_file$ = dev$ & f$ & "_bas"
32745 OPEN_IN#5,input_file$:OPEN_OVER#6,output_file$
32746 l = f
32747 REPeat number
32748 INPUT#5,l$ : PRINT#6,IDEC$(l,5,0);" ";l$
32749 IF EOF(#5) THEN EXIT number : ELSE l=l+d
32750 END REPeat number
32751 CLOSE#6:CLOSE#5:RETurn l
32752 END DEFine aln
32753 DEFine FuNction mwoln(f$,ff,d)
32754 ll=aln(f$,ff,d): ff$ = dev$ & f$ & "_bas"
32755 MERGE ff$ : RETurn ll
32756 END DEFine mwoln
32757 DEFine PROCedure BYE
32758 PAPER#3,0:INK#3,4:CSIZE#3,0,0:CLS#3:AT#3,0,7
32759 PRINT#3,' F1',,'F2',,'F3',,'F4',,'F5':RESTORE OK
32760 FOR i = 5 TO 69 STEP 16
32761 READ p,q,p$,Q$:PAPER#3,p:INK#3,q
32762 AT#3,1,i:PRINT#3,p$:AT#3,2,i:PRINT#3,Q$
32763 END FOR i
32764 p = CODE(INKEY$(-1))/4
32765 IF p<58 OR p>62 : GO TO 32764
32766 CLS#0:CLS:CLS#2:GO TO p+OK-53
32767 END DEFine BYE
PRINT aln("MANIFEST",1,1)
MRUN mdv1_MANIFEST_bas
Code: Select all
DLINE 1 to KO
BYE
After loading these, BOOT will immediately execute two commands (statements without line numbers) : a call to ALN to add line numbers to a file called mdv1_MANIFEST_txt that will output a file called mdv1_MANIFEST_bas and MRUN (Merge and Run) it.
This is my first idea of the MANIFEST file mdv1_MANIFEST_txt :
Code: Select all
LRESPR 'mdv1_ptr_gen'
LRESPR 'mdv1_MacMouse11'
LRESPR 'mdv1_wman'
rem LRESPR 'mdv1_sys_hot_rext'
LRESPR 'mdv1_Qptr'
rem LRESPR 'mdv1_sys_Qpac2'
rem LRESPR 'mdv1_fileinfo2_bin'
window#0,512,256,0,0:paper#0,0;:ink#0,0;: cls#0
CLS#0:WINDOW#0,388,42,110,0:PAPER#0,2;:INK#0,7:BORDER#0,1,7
WINDOW#1,94,225,14,0:PAPER#1,0;:INK#1,7:BORDER#1,1,7
WINDOW#2,388,182,110,43:PAPER#2,0;:INK#2,4:BORDER#2,1,7
OPEN#3,'scr_512x31a0x225':PAPER#3,0;:INK#3,4
CFO=32601
R = ALN("CFORMS",CFO,1)
TMO = R+1
R = ALN("TOP_MENU",TMO,1)
PMO = R+1
R = aln("PSION_MENU",PMO,1)
LMO = R+1
R = ALN("LANG_MENU",LMO,1)
CMO = R+1
R = ALN("C68_MENU",CMO,1)
MERGE mdv1_C68_MENU_bas
MERGE mdv1_LANG_MENU_bas
MERGE mdv1_PSION_MENU_bas
MERGE mdv1_TOP_MENU_bas
MERGE mdv1_CFORMS_bas
INITFORM
OK = TMO : KO = CFO-1
Finally, one numbered statement outside PROcedure or FuNction :
Code: Select all
32741 MRUN mdv1_TOOB