How to use SIZE in an AOI

TheWaterboy

Lifetime Supporting Member + Moderator
Join Date
May 2006
Location
-27.9679796,153.419016
Posts
1,906
How do I use SIZE in an AOI as a InOut param?

I want to pass an array of unknown size (up to a hard limit) to an AOI as InOut param, then in the AOI compare for changes using a previous copy of the source array with FSC and an interval timer. This works well in ladder when everything is defined, but when trying to make it more generic for multiple uses I need to determine what size I have passed it and I can't get SIZE to accept any source parameter I type in with or without [Element].
 
I suspect that what you're trying to do is not officially supported, and may not work. But I haven't tried, and if there's one thing I like about AB, it's that it often lets you do inventive things that aren't necessarily supported! Interested to see if you can get it working!

Can you trick it into working by coding it as SourceArray[Pointer] and setting Pointer to zero? If it's got an indirect address in there, it may not bother to check it for validity.
 
I hate to be that guy, but you are 100% sure that SourceArray is defined as an array, correct?

What you are doing is supported. The way I have used it in the past is to define an array as an InOut parameter in an AOI with an array size of 1 in all dimensions. The [1] is the indicator to Logix that this is a variable sized array, since an array of size 1 is unreasonable; its a single tag. However, SIZE will work on any array defined in any scope.

Keith
 
Hmmm, you may have the key so you can be that guy all you want.

The source array doesn't yet exist in the dev stage of this AOI because when used the size would not yet be known. Soooo I was thinking it was just a placeholder and didn't need to exist yet.... but since you brought it up... I might be wrong about that.
 
This is not only supported, it is recommended. From https://literature.rockwellautomation.com/idc/groups/literature/documents/pm/1756-pm010_-en-p.pdf

The InOut parameter can be defined to be a single dimension array. When
specifying the size of this array, consider that the user of your array can
either:
• Pass an array tag that is the same size as your definition.
• Pass an array tag that is larger than your definition.
When developing your logic, use the Size instruction to determine the actual
size of the referenced array to accommodate this flexibility.
 
Very good. In the AOI just define it as SourceArray[1] of whatever data type it is and you will be golden. I think it will need to be an InOut, though. But I might be wrong about that as well.

Keith
 
Yes, it does have to be InOut.

Strictly speaking the [size] defines the smallest size that can be passed to it; setting it to [1] guarantees it will work with any size.
 
Originally posted by plvlce:

Strictly speaking the [size] defines the smallest size that can be passed to it; setting it to [1] guarantees it will work with any size.

What version did that come in at? I have a V24 program I am playing with. Unless I set the array size of the InOut parameter to 1, V24 requires the size of the array parameter at the AOI call instance to be the same size as the InOut array size .

Keith
 
What version did that come in at? I have a V24 program I am playing with. Unless I set the array size of the InOut parameter to 1, V24 requires the size of the array parameter at the AOI call instance to be the same size as the InOut array size .

Keith

The Add-On Instruction manual I linked above includes an example of an InOut parameter that is a 10-element DINT array, but the end user passes a 100-element array.

I'm just going by what the manual says, I've never used anything except size 1 myself -- if I want to ensure a minimum array size I use SIZE to check it.

EDIT: I don't have a controller handy atm to test online, but testing offline with V24 I can set the array size of the parameter to 10 then give it a size 30 array with no errors.
 
Last edited:
Well I'll be, it is supported! That's the second new trick I've learned today, and it's a good one!
 
Originally posted by plvlce:
...with V24 I can set the array size of the parameter to 10 then give it a size 30 array with no errors.

You are correct. My bad. I inadvertently went the other way with the array size (5 element AOI input into a 10 element InOut array). The way you stated it works just fine.

Keith
 

Similar Topics

I have a AOI, inside I have a 'Str_Source' declared as INOUT with STRING data type. It works fine using the same string data type, but I want...
Replies
10
Views
2,862
I looked into this a little bit a while back but now have an application where it would make life soooo much more simple if this is possible...
Replies
9
Views
3,865
Hello, I have a quick question. I have been using scripts to change the color of buttons. The reason, I am usually using multiple hmiruntime.tags...
Replies
1
Views
82
Supposing I want to be put a TIA Portal Project "executable image" onto a memory card (e.g. see picture). The reason for doing this is so that I...
Replies
8
Views
326
Hi all, I am having an issue with FT View Studio ME when I try to open the propoerties of any object, the size of it is very big and doesn't let...
Replies
0
Views
96
Back
Top Bottom