Unity Pro ANY_ARRAY Base Index

Schnider

Member
Join Date
Aug 2016
Location
Perth
Posts
15
Hi,

Unity has the option to index its arrays between any two numbers; e.g. "ARRAY[13..27] OF INT".

I am writing a DFB which needs to take in a variable size array. Does anyone know how to determine the base (lowest value in array) of an ANY_ARRAY, or if there are some tricks to addressing the array without getting an overflow error? I am aware of "LENGTH()" to determine the length of the array.

FYI, this is Unity v13.1 with an M580.

Cheers
 
You can use EXTRACT block, it uses zero based addressing for input.
Extract your array to fixed array lenght, and then compare from position 0 or 1 on new array with lenght?
 
With extract you need to remember that it uses bytes for copying so lenght is 2x array for block (for integers). Extract block gives easily error and data is not copied if parameters are wrong)


Both start and destination positions are now 0.


Input and output arrays don't need to be same lenght.



You can build your own DFB block, then inside block use extract block and locate you input array (original data) to new fixed lenght (like 0.999) or something.
(You can even locate your temp array to output of block (any array type, so you can save little bit memory as you can only make temp variable as long as you need every time, but whit M580 memory won't be prolem like P57 series.)


There is old thread of extract:


http://www.plctalk.net/qanda/showthread.php?t=85103
 
Last edited:

Similar Topics

I created an DINT array in Unity Pro. How do I get to the bit level? DINT_rcv expands to DINT_rcv[0] & DINT_rcv[1] but I want to address a bit at...
Replies
3
Views
2,324
I am trying to make a function that count the number of True BOOL inn a specific Array and return the count to an INT AlarmArrayActiveAlarms. I...
Replies
8
Views
4,440
I am using Unity Pro XL 4.1 and have a question. I am used to programming on Allen Bradley and this was possible in ControlLogix. I have 16...
Replies
2
Views
5,061
in unity ,every time when i call a fb,it makes a instance of this fb,i want to define an array instance of a fb,but i don't know if it's permitted ?
Replies
9
Views
4,394
Hello, I am using Unity pro V15. I have Quantum CPU 671 and Ethernet NOE 77101 configured. I have configured IO scanning on NOE. I have attached...
Replies
5
Views
177
Back
Top Bottom