Author Topic: Looking for unused variables  (Read 13488 times)

cch1955

  • Full Member
  • Posts: 198
  • Automated Machine Systems Designer
    • View Profile
Looking for unused variables
« on: February 05, 2014, 04:50:24 PM »
I know I can see varibles values with the simulator etc. I would like to know if a variable has been used in a custom function within a program. I can do the find all and try to hit the right combination that will find it, but sometimes this is not easy.

I track the variables in a spreadsheet as I assign them, but some old well hacked and revised programs can get a bit out of control with last minute hacks and documentation doesnt always keep up.

Thanks

garysdickinson

  • Hero Member
  • Posts: 502
  • Old PLC Coder
    • View Profile
Re:Looking for unused variables
« Reply #1 on: February 05, 2014, 05:41:46 PM »
I don't have a perfect answer for how to find variable usage in a TBASIC program.  

You are using all of the tools that are provided in the i-TRiLOGI software.  You might want to export the custom functions to a text file and look at the functions using a text editor outside of the i-TRiLOGI.

To export the custom functions:
   Select File->Print to bring up the Print Control Panel
   In the "Print : " box select "Custom Functions"
   An "Export" button will now appear... Click on this and specify and location and file name to save the custom functions.

I use the "free" text editor, Notepad++.  Since all of the custom functions are now in a single file, it makes searching much easier.  

If you edit the exported file, the only way to get the edits back into your ".PC6" file is to cut and paste between Notepad++ and i-TRiLOGI.  They don't have a matching "Import", but at least they have an "Export".

I use the #Define mechanism in TBASIC to create additional integer variables using DM[] memory.  These variables can have much more descriptive names than A..Z and make the program a bit easier to read/maintain.  In a way this allows me to create variables that are "local" to a custom function.  

Best regards,

Gary d

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re:Looking for unused variables
« Reply #2 on: February 05, 2014, 08:47:57 PM »
Thanks for the suggestions, Gary.

Here is another helpful facility:

When you open a custom function you can select a variable name using the mouse. Then the help panel will tell you which custom functions the highlighted text appears in. It can be a quick way to look for unique variable names such as DM[xxx]. It won't be very useful if your variable is a single letter such as A to Z.  But if you have named your variable such  A_beancounter or M_money  etc then it is probably quite easy to see where the same name appears in the custom functions.

In the following example you can tell that the variable DM[163] is used in custom function #19, 21, 40 and 41.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

cch1955

  • Full Member
  • Posts: 198
  • Automated Machine Systems Designer
    • View Profile
Re:Looking for unused variables
« Reply #3 on: February 06, 2014, 08:44:40 AM »
I appreciate both of your replies, very helpful! I must admit I got out of the habit of reading the manual since it didn't change too often. I did the custom function export - very handy really makes documenting programs a bit easier.

I saw the #define table addition but have not used it to date, so I will give it a go, helps keep track of things and reduce those keystrokes and typos.

The real find I seemed to miss is the ability to add 32bit variables when you need them beyond the 26 A=Z variables from earlier versions GREAT FEATURE! Thanks to the folks at TRI.

So in the next update when you are looking for great new functions, add a STEP HOLD so you can decel to a stop and hold at zero step speed and STEP RESUME to complete the initial STEPMOVE move. It can be done in other ways but it is tedious.
 :)
Great reliable, powerful, PLC'S keep up the good work!
« Last Edit: February 06, 2014, 09:00:10 AM by cch1955 »