| Posted: 11:04am 17 Jan 2018 |
Copy link to clipboard |
 Print this post |
|
Hi Rico and welcome to the forums!
I initially didn't think there could be much saving, but you are right !(depending on your code) yes there can be....the following is an extreme example using MM for DOS
Open "testML1.bas" For Output As #1 ? #1,"Timer=0" For i=10001 to 20000 ? #1,"x%=";i;Chr$(13); Next i ? #1,"? Timer" ? #1,"MEMORY" ? #1,"Load "Chr$(34)"TestML2.bas"Chr$(34)",R" Close #1
Open "testML2.bas" For Output As #1 ? #1,"Timer=0" For i=10001 to 20000 ? #1,"x%=";i; If i mod 25 Then ? #1,":"; Else ? #1,Chr$(13); Next i ? #1,"? Timer" ? #1,"MEMORY" Close #1
? "Running 10000 instructions in two files, first is one instruction-per-line, second is 25 instructions per line" Load "TestML1.bas",R
Gives a saving of 28k
DOS MMBasic Ver 5.04.08 Copyright 2011-2017 Geoff Graham
Running 10000 instructions in two files, first is one instruction-per-line, second is 25 instructions per line 31 Program: 137K (26%) used 375K free (10004 lines) Variables: 0K ( 0%) used 31K free (1 variables) General RAM: 0K ( 0%) used 512K free 16 Program: 109K (21%) used 403K free (403 lines) Variables: 0K ( 0%) used 31K free (1 variables) General RAM: 0K ( 0%) used 512K free >
Also note you can compress your code more by removing spaces...for your exampledo:loop until INPUT$(255,#1)=""
Multiple subs on one line work, as well as multiple functions (like a=function1():b=function2() as well as nesting of functions) When using 'IF' statements you need to carefully read the manual and do some tests to make sure you understand the subtle differences in syntax. If misunderstood, this can cause programs to jump early out of your IF construct to the next line whereas you may have expected it to go to the next statement (after the IF construct) on the same line, but it doesn't.
Maximum length of a command line is 255 characters(it's in the manual). I've found 256 char lines work for some commands(e.g. ending in ") but I wouldn't risk it without extensive testing.
Hope this helps and have fun and good luck!
Regards,Phil Edited by flip 2018-01-18 |