Goal
I am programming an Allen-Bradley / Rockwell CompactLogix PLC
in SCL
. I would like to determine the size of Arrays
at runtime. It would be possible to enter the Array
lengths as constants
into the code before compiling. However, the reusability would be improved greatly if the lengths of the arrays could be determined automatically.
Problem
There is the function SIZE(Source,Dimtovary,Size)
which does exactly what I need although only for SINT[]
INT[]
DINT[]
REAL[]
structure
and STRING
. Unfortunately I need the length of BOOL[]
.
"The SIZE instruction finds the number of elements (size) in the designated dimension of the Source array or string operand and places the result in the Size operand. The instruction finds the size of one dimension of an array."
Pseudo code
Int_array := INT[16];
Bool_array := BOOL[64];
SIZE(Int_array[0],0,Int_array_len);
// Works, Int_array_len contains 16
SIZE(Bool_array[0],0,Bool_array_len);
// Isn't compilable becaus size(); isn't defined for boolean arrays
Environment
- IDE: Rockwell Studio 5000 / RSLogix 5000
- PLC: 1769-L36ERMS
- Language: SCL (Structured text)
- Reference: Programming reference manual
Question
Is there a way to determine the length of a boolean array for example BOOL[64]
?
Additionally, is there a fundamental reason why SIZE(Source,Dimtovary,Size);
doesn't work with boolean arrays?