Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 22:14 10 Nov 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Micromite - ":" operator

Author Message
rhiemann
Newbie

Joined: 24/11/2017
Location: Germany
Posts: 12
Posted: 09:53am 17 Jan 2018
Copy link to clipboard 
Print this post

In general the ":" operator could be used to save lines.
Like:

do : loop until INPUT$(255, #1) = ""


Looking at the memory command: less amount of lines means less amount of used flash
> memory
Flash:
57K (57%) Program (1234 lines)
11K (10%) 5 Embedded C Routines
4K ( 4%) Library
28K (29%) Free

Could the ":" operator be used to reduce the amount of used flash?
What are the limitations of the : operator? Amount of characters per line....?

I noticed in some cases of my "optimized" line amount code that the program behaved differently.

Are constructs possible like:

function1() : function2() : function3() : function4() : function5() : function6()


Thanks in advance
Rico
 
flip
Senior Member

Joined: 18/07/2016
Location: Australia
Posts: 117
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 example
do: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
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025