News:

  • September 22, 2026, 11:18:05 AM

Login with username, password and session length

Author Topic: Used Variables  (Read 15272 times)

RBPLC

  • Hero Member
  • *****
  • Posts: 586
Used Variables
« on: April 04, 2020, 07:51:19 PM »
See attached for reference. I'm using V900-V989 in this program and these variables have assigned nicknames. Why when I use the Element Picker do these variables show up as not in use? For example, V900 is selected and you can see its nickname in the top of the element picker box but down at the bottom, there is no "x" in the V900 box. 

Garyhlucas

  • Hero Member
  • *****
  • Posts: 421
Re: Used Variables
« Reply #1 on: April 05, 2020, 09:01:00 AM »
I believe nicknames do not confer use. You can start building a program by naming all the variables you intend to use and none of them are shown as used until a rung references them.

b_carlton

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 606
    • thePLCguy
Re: Used Variables
« Reply #2 on: April 05, 2020, 09:48:35 AM »
Are they being referenced indirectly?
An output is a PLC's way of getting its inputs to change.

RBPLC

  • Hero Member
  • *****
  • Posts: 586
Re: Used Variables
« Reply #3 on: April 05, 2020, 11:21:34 AM »
These specific ones are being referenced indirectly. I guess that's why they're not showing up as in use. It would be nice if they did.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3847
    • Host Engineering
Re: Used Variables
« Reply #4 on: April 05, 2020, 11:24:02 AM »
These specific ones are being referenced indirectly. I guess that's why they're not showing up as in use. It would be nice if they did.

Do you mean via an array reference?  Or other mechanism (e.g. HMI or remote PLC or ? ? ?)

RBPLC

  • Hero Member
  • *****
  • Posts: 586
Re: Used Variables
« Reply #5 on: April 05, 2020, 11:46:02 AM »
For example (within DmD), 978 is copied to V15. A Math expression stores a value in V[V15]. Another math expression is used to store a value in V[V15+1] and a comparison is made between V[15] and V[V15 +1]. V memory locations 978 and 979 have values stored in them and are being used, they're just being referenced in Copy and Math commands. 

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6176
  • Yes Pinky, Do-more will control the world!
Re: Used Variables
« Reply #6 on: April 05, 2020, 12:08:24 PM »
For example (within DmD), 978 is copied to V15. A Math expression stores a value in V[V15]. Another math expression is used to store a value in V[V15+1] and a comparison is made between V[15] and V[V15 +1]. V memory locations 978 and 979 have values stored in them and are being used, they're just being referenced in Copy and Math commands.

There is no way to know what is being used when it is indirectly referenced (by array index). The best thing to do is to allocate a memory block to use for data like that.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3626
  • Darth Ladder
Re: Used Variables
« Reply #7 on: April 05, 2020, 01:52:16 PM »
These specific ones are being referenced indirectly. I guess that's why they're not showing up as in use. It would be nice if they did.

But how can DMD enumerate what values the index might take at runtime and flag the referenced registers as used?  I guess DMD could allow the programmer wherever there is an indirect reference to manually flag registers that he expects to be referenced.
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3626
  • Darth Ladder
Re: Used Variables
« Reply #8 on: April 05, 2020, 02:00:23 PM »
The best thing to do is to allocate a memory block to use for data like that.

That works!
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

ATU

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 2126
  • YKPAIHA
    • ATU, Inc.
Re: Used Variables
« Reply #9 on: April 05, 2020, 03:18:57 PM »
Whenever I use an array, I use a memclear in my initialization stages, even if I don't believe I need it. That way it shows up in the picker as used.

RBPLC

  • Hero Member
  • *****
  • Posts: 586
Re: Used Variables
« Reply #10 on: April 06, 2020, 06:24:12 PM »
Thanks for the feedback guys. I like ATU's suggestion of memclear to at least signify that they're possibly being used. I also like the idea of being able to manually select them as Controls Guys suggested.