Author Topic: Is Reading Array Size Possible?  (Read 2273 times)

M4

  • Newbie
  • *
  • Posts: 10
    • View Profile
Is Reading Array Size Possible?
« on: January 26, 2022, 10:50:19 PM »
Is there a way to read array size? In this case I am expecting 30
« Last Edit: January 26, 2022, 10:53:41 PM by M4 »


dmroeder

  • Administrator
  • Full Member
  • *****
  • Posts: 212
    • View Profile
Re: Is Reading Array Size Possible?
« Reply #2 on: January 27, 2022, 12:25:26 PM »
Is there a way to read array size? In this case I am expecting 30

Clarification question:  Are you wanting to provide a tag name and have the driver tell you what size the array is?  I don't think the driver will do that via Read.  What I would do is in your PLC, use the SIZE instruction, then read the result tag of the SIZE instruction.

M4

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Is Reading Array Size Possible?
« Reply #3 on: January 27, 2022, 05:26:16 PM »
It would be nice to have that array length finding in driver. What I did was use a button to start read (index loop) and driver throws tag not found error, where I use that catch exception to index length value to text box

dmroeder

  • Administrator
  • Full Member
  • *****
  • Posts: 212
    • View Profile
Re: Is Reading Array Size Possible?
« Reply #4 on: January 27, 2022, 05:44:39 PM »
It would be nice to have that array length finding in driver. What I did was use a button to start read (index loop) and driver throws tag not found error, where I use that catch exception to index length value to text box

I agree it would be nice, but there isn't a CIP object that is "hey tag, what is your length?".  It is possible to get a tags array size when retrieving the tag list.  I know Archie had a tag browser tool, not sure if that is baked into the main AdvancedHMI drivers.  Archie can comment on that.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Is Reading Array Size Possible?
« Reply #5 on: April 03, 2022, 08:35:19 AM »
If you use the GetTagList function, it will return the array of tags and that information contains some properties that can be used to get the information you want:

TagName
NumberOfBytes
ArrayElements1
ArrayElements2
ArrayElements3
NumberOfDimensions