Internet PLC Forum

General => Technical support => Topic started by: TTCSR on September 24, 2012, 04:52:46 AM

Title: Saving space
Post by: TTCSR on September 24, 2012, 04:52:46 AM
I have a very large program, however, there are a lot of areas that have repeat commands such as:

SETLCD 0,0, CHR$(1)
SETLCD 1,1,A$

Is there anyway to put the entire "SETLCD...." into a string?

Or any other tips for space saving would be appreciated.
Title: Re:Saving space
Post by: support on September 24, 2012, 04:43:45 PM
You could put the repeat command inside a custom function that you call whenever you want to run these command.

e.g. if you put the two commands inside a CF named "DisplayLCD"

SETLCD 0,0, CHR$(1)  ' clear screen
SETLCD 1,1, A$

In other parts of your program, you will assign the string to be displayed on line 1 to A$ then CALL DisplayLCD:

E.g.

A$ = "Hello " + STR$(TIME[1]) + ":" + STR$(TIME[2])
CALL DisplayLCD

 
Title: Re:Saving space
Post by: TTCSR on September 25, 2012, 09:48:06 AM
Makes the program a little bit harder to follow, but it saved a significant amount of space.  Thank you  ;D
Title: Re:Saving space
Post by: support on September 25, 2012, 12:27:18 PM
If you are using i-TRiLOGI version 6.4x you can simply use your mouse to select the function name (DisplayLCD) and it will open up a read only text windows to show you the content of the DisplayLCD function. That should help you to follow the program more easily.
Title: Re:Saving space
Post by: TTCSR on October 01, 2012, 08:19:03 AM
That's a neat little trick, unfortunately,  I inserted the code as
CALL 1, CALL 2, etc.... to save additional space and the trick doesn't work unless I use the name.
Title: Re:Saving space
Post by: support on October 01, 2012, 08:34:21 AM
Note that using the function number instead of the function name DOES NOT save any program code space after compilation since they are translated to the identical code. However, it does retain the flexibility of renaming the custom function label without having to search and replace in all the places that it has been called.