News:

  • October 27, 2025, 06:55:07 AM

Login with username, password and session length

Author Topic: Naming of Data Block Number Restriction  (Read 4395 times)

ATU

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 2126
  • YKPAIHA
    • ATU, Inc.
Naming of Data Block Number Restriction
« on: April 12, 2018, 02:13:32 PM »
I am finding good uses for the UDTs. However, why is there a ban of using a number in the Memory Block Tag definition? Could you not limit that to no numbers on the first and last character? Not having the capability of using a number in the tag, especially since it is limited to a 16 character width is a handicap. Machines typically have many things designated by a number, ie  stations, nodes, cutters, heaters, etc. If I have to spell out or abbreviate the number, that takes up half the tag length and using a letter designation is just something you don't see.  
« Last Edit: April 12, 2018, 02:38:41 PM by ATU »

LWgreys

  • Hero Member
  • *****
  • Posts: 117
Re: Naming of Data Block Number Restriction
« Reply #1 on: April 13, 2018, 06:41:54 AM »
You can uise digits in the naming of code blocks. There are limitation to the name of the code-block.

Code-block names can be 1 to 16 characters in length and consist of any combination of alphanumeric characters and underscores ('_', 'a-z', 'A-Z', 0-9), no spaces or punctuation marks are allowed, and must begin with a letter or an underscore.

Also reserve names cannot be used also.

Legal Names:
_1
MyProgram1
machine_1

Not Legal Names:
1
1m
machine 1
« Last Edit: April 13, 2018, 06:47:17 AM by LWgreys »

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6127
  • Yes Pinky, Do-more will control the world!
Re: Naming of Data Block Number Restriction
« Reply #2 on: April 13, 2018, 09:06:12 AM »
I'd say embedded numbers could be done, but the parsing is already pretty ugly between block names, heap names, nicknames, and all cast flavors. And it's made worse by the symbolic driver support. The PLC needs to do its work very efficiently, and numbers in block names throws another ugly wrinkle that would further complicate it.

Unless you need array indexing, you could create the UDT as a singleton on the heap. Additionally, you can use a nickname for a UDT element or heap item.
"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

ATU

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 2126
  • YKPAIHA
    • ATU, Inc.
Re: Naming of Data Block Number Restriction
« Reply #3 on: April 14, 2018, 01:49:47 PM »
Unless you need array indexing

Yes, all my custom heap variables are arrays. That's when its most useful. Well, keep in mind if the opportunity arises and its easy to implement.

PLCGuy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 677
Re: Naming of Data Block Number Restriction
« Reply #4 on: April 14, 2018, 05:06:16 PM »
After reading this, what is the reason that a number can not be the first thing in a name? Is there something how the programming language its-self works? I work with another company also where a number can not be use first in a tag name. so instead of 60_InchWheel, I have to write sixty_inchWheel.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6127
  • Yes Pinky, Do-more will control the world!
Re: Naming of Data Block Number Restriction
« Reply #5 on: April 14, 2018, 05:48:34 PM »
Our names are modeled C/C++/java language rules. I'm sure there are many things possible, but we went with what we know.
"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

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3762
    • Host Engineering
Re: Naming of Data Block Number Restriction
« Reply #6 on: April 14, 2018, 06:21:51 PM »
After reading this, what is the reason that a number can not be the first thing in a name? Is there something how the programming language its-self works? I work with another company also where a number can not be use first in a tag name. so instead of 60_InchWheel, I have to write sixty_inchWheel.

Grammars and parsing for computer languages are this way for many technical reasons.  For example 6E5 can be a block named 6E, with ID 5.  But it is ALSO the representation for the floating point number 600000 (exponential notation).  Sadly, computers don't know the difference, hence the need for precise grammars.  Similar with 6E-5.  In a MATH expression, is this the nickname/tag 6E and I want to subtract 5, or is it the exponential notation for 0.000006?  The rules in a MATH expression get even more difficult if we allowed whitespace in our nickname/tags.

Trust me, these rules have been around a LONG time - Host Engineering did not invent them.   ;D

LWgreys

  • Hero Member
  • *****
  • Posts: 117
Re: Naming of Data Block Number Restriction
« Reply #7 on: April 15, 2018, 11:27:07 AM »
I made a wrong reply to this topic. Being half a sleep when I made the reply, I overlooked the "Memory Block" type.

It would be a conflict of trying to address for example, Memory Block zzThree and zz3. Memory Block zzThree1 is definably but zz31 is not because the program parsing can not differentiate zz3'1' from zz31 in your program.

Now if one could define a Memory Block like zz3_, then your program parsing would be able to differentiate zz3_1 and zz3_2.

You can do what you want by using "User Data Types."
First goto (System Configuration), select <Memory Configuration> then <User Data Types> then <Add User Data Type>.
Click <Add>. You should be here in pic3 below.
Give a name for the Field, then Data Type. If it's going to be a status only then select Read-Only under Read/Write.
You can duplicate the Field by highlighting the field and click <Duplicate> as many times you needed.
When you are finished defining you new Data Type, click <OK>.
You should see a response like in pic6 below.
Click <Memory Block> and the Add Block dialog will appear.
Give the new Memory Block a "Name". Be sure the Data Type is correctly selected. Set the Block Range and the Retentive Range.
Now you have a new "Memory Block" called "Machine".
Click <OK>.
Under Project Browser you can see the new memory block under Configuration, User, Structures, then a breakdown of the structure.
Then all you have to do is use it like in the last pic.
« Last Edit: April 15, 2018, 11:40:55 AM by LWgreys »

LWgreys

  • Hero Member
  • *****
  • Posts: 117
Re: Naming of Data Block Number Restriction
« Reply #8 on: April 15, 2018, 11:28:57 AM »
More Pics

LWgreys

  • Hero Member
  • *****
  • Posts: 117
Re: Naming of Data Block Number Restriction
« Reply #9 on: April 15, 2018, 11:30:16 AM »
Last Pics
« Last Edit: April 15, 2018, 11:45:41 AM by LWgreys »

LWgreys

  • Hero Member
  • *****
  • Posts: 117
Re: Naming of Data Block Number Restriction
« Reply #10 on: April 15, 2018, 11:35:25 AM »
That all there is to creating a Memory Block named Machine0, Machine1....