AdvancedHMI Software

General Category => Open Discussion => Topic started by: M4 on January 26, 2022, 10:50:19 PM

Title: Is Reading Array Size Possible?
Post by: M4 on January 26, 2022, 10:50:19 PM
Is there a way to read array size? In this case I am expecting 30
Title: Re: Is Reading Array Size Possible?
Post by: profnova on January 27, 2022, 07:42:27 AM
try this

https://docs.microsoft.com/fr-fr/dotnet/api/microsoft.visualbasic.information.ubound?view=net-6.0
Title: Re: Is Reading Array Size Possible?
Post by: dmroeder 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.
Title: Re: Is Reading Array Size Possible?
Post by: M4 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
Title: Re: Is Reading Array Size Possible?
Post by: dmroeder 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.
Title: Re: Is Reading Array Size Possible?
Post by: Archie 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