Author Topic: Saving space  (Read 12991 times)

TTCSR

  • Newbie
  • Posts: 30
  • I'm a llama!
    • View Profile
Saving space
« 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.

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:Saving space
« Reply #1 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

 
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

TTCSR

  • Newbie
  • Posts: 30
  • I'm a llama!
    • View Profile
Re:Saving space
« Reply #2 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

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:Saving space
« Reply #3 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.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

TTCSR

  • Newbie
  • Posts: 30
  • I'm a llama!
    • View Profile
Re:Saving space
« Reply #4 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.

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:Saving space
« Reply #5 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.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS