News:

  • October 01, 2026, 07:23:00 AM

Login with username, password and session length

Author Topic: Symbolic Constants  (Read 18034 times)

ATU

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 2126
  • YKPAIHA
    • ATU, Inc.
Symbolic Constants
« on: January 03, 2019, 11:27:41 AM »
I just found this tool in the documentation editor a  few days ago and its a real gem.  I knew it was somewhere, but its kind of buried in the help under the Documentation Editor.  I looked for it first under topics, typing in "constant"  for a keyword.  Nothing really came up. Then I did a search for "Constant" and ended up in help for the doc editor, but still took a lot of searching in the page to gather all the information on it.   I think it would be very helpful to add a brief summary as a separate topic on it in the help, sometime in the future when updating the help.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3847
    • Host Engineering
Re: Symbolic Constants
« Reply #1 on: January 03, 2019, 12:59:04 PM »
It's also in the Create Nickname dialog.  It's one of the options (see attachment).

I like to use them for date/time constants:
Jan=1 Feb=2, ... Dec=12
Sun=0, Mon=1, ... Sat=6

First Sunday after the first Saturday in November becomes
Code: [Select]
$Now.DayOfWeek Sun     $Now.Month Nov     $Now.Day 2     $Now.Day 8
----------] = [------------] = [------------] >= [---------] <= [----------
« Last Edit: January 03, 2019, 03:46:49 PM by franji1 »

ATU

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 2126
  • YKPAIHA
    • ATU, Inc.
Re: Symbolic Constants
« Reply #2 on: January 03, 2019, 01:45:18 PM »
Having them grouped together in the Doc Table also helps organize the list and makes it easy for others to change program constants. I like to use all caps to differentiate them from other variables in the ladder.

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3626
  • Darth Ladder
Re: Symbolic Constants
« Reply #3 on: January 03, 2019, 03:01:10 PM »
I just found this tool in the documentation editor a  few days ago and its a real gem.  I knew it was somewhere, but its kind of buried in the help under the Documentation Editor.  I looked for it first under topics, typing in "constant"  for a keyword.  Nothing really came up. Then I did a search for "Constant" and ended up in help for the doc editor, but still took a lot of searching in the page to gather all the information on it.   I think it would be very helpful to add a brief summary as a separate topic on it in the help, sometime in the future when updating the help.

Oh, you've been missing out.  Constants good!  I missed TI's K-Memory when working on AB.  At least in the SLC, you could mark a certain data file static, and you'd get about the same thing, but nothing like that in the CLX.  I called AB once and asked them how to get a constant (being pretty sure there wasn't actually a way).  They told me to create a variable (tag) and write to it in ladder.  I asked if they thought I should be using a "variable" when I was trying to get a "constant", but they didn't think there was an issue. [facepalm]
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: Symbolic Constants
« Reply #4 on: January 03, 2019, 03:04:24 PM »
Having them grouped together in the Doc Table also helps organize the list and makes it easy for others to change program constants. I like to use all caps to differentiate them from other variables in the ladder.

I actually think the UI could use some tweaking.  Maybe move them to the heap item dialog and let you check a box for constant or something.  Not sure what it needs but feels a bit awkward now.
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: Symbolic Constants
« Reply #5 on: January 03, 2019, 03:12:44 PM »
RS5000 has a check box, but that only prevents you from changing it in the ladder when online, but you can set the value in the tag list and it does the same thing.  Omron has nothing like it, but it's been about 5 years since I have done any programing. I would like to see some way for strings to be stored as constants. Perhaps a separate table somewhere to encompass all constants, but that might be tricky with the existing format.

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3626
  • Darth Ladder
Re: Symbolic Constants
« Reply #6 on: January 03, 2019, 03:27:04 PM »
RS5000 has a check box, but that only prevents you from changing it in the ladder when online, but you can set the value in the tag list and it does the same thing.

My experience was from like Y2K and they didn't have it then.  I'd forgotten they put that in.   I was also happy when they decided to bring back what the SLC and PLC-5 could do 30 years ago and view array tags of appropriate types in a tabular fashion, instead of wasting 95% of your screen space on stuff that wasn't live data in that awful spreadsheet.

Quote
I would like to see some way for strings to be stored as constants. Perhaps a separate table somewhere to encompass all constants, but that might be tricky with the existing format.

Yeah, I'd like that too.
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3847
    • Host Engineering
Re: Symbolic Constants
« Reply #7 on: January 03, 2019, 03:45:22 PM »
I missed TI's K-Memory when working on AB.

However, TI's K-Memory, you could do the following
K1=0
K2=1
K3=2
K4=3

Most TI programmers were smart and reserved the first few K's as the obvious
K0=0
K1=1
K2=2

RussS @ADC worked on the vork editor in TISOFT!

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3626
  • Darth Ladder
Re: Symbolic Constants
« Reply #8 on: January 03, 2019, 04:13:10 PM »
However, TI's K-Memory, you could do the following
K1=0
K2=1
K3=2
K4=3

But that wasn't really problematic for people not already used to platforms like the 405 where "K1" means "1".  It was like seeing V2035, just a register address.

Plus, I think since they were registers you could do descriptions and, iirc, even synonyms, just like any other type memory.  Am I remembering that right?

I'd done tons of 5x0 and 5x5 work by the time I saw my first 405, so I had the reverse problem.  I'd see "K4" and think it was a named constant rather than a literal.  If you want a literal, just type "4"!
« Last Edit: January 03, 2019, 04:32:15 PM by Controls Guy »
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3847
    • Host Engineering
Re: Symbolic Constants
« Reply #9 on: January 03, 2019, 04:38:20 PM »

But that wasn't really problematic for people not already used to platforms like the 405 where "K1" means "1".  It was like seeing V2035, just a register address.

Yes.  K memory was memory.  For some PLC systems (560?), it could be a pluggable ROM.  So you could change the units static "recipe" by swapping out the K memory ROM chip with a different chip.

And if it was K2. it was a 32-bit floating point constant (note the period after the K2).  It would take up K2 and K3.

PLCGuy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 677
Re: Symbolic Constants
« Reply #10 on: January 04, 2019, 01:46:22 PM »
can these be made to hold strings or other types of data?

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6176
  • Yes Pinky, Do-more will control the world!
Re: Symbolic Constants
« Reply #11 on: January 04, 2019, 02:39:49 PM »
can these be made to hold strings or other types of data?

No, just numeric values.
"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