SetArrayLength(Cache, ArrayIn.Length);
Cache[i] := ArrayIn.asArray(i) * 0.5;
| Procedure | Description |
|---|---|
procedure SetArrayLength(var A: dynamic-array; NewLength: Integer); |
Set the length of a dynamic array |
function GetArrayLength(A: dynamic-array): Integer; |
Get the length of a dynamic array |
procedure SetArrayLength(var A: dynamic-array; NewLength: Integer);
Resizes a dynamic array declared in script code.
var ArrayIn : TParameter;
var Cache : array of single; // dynamic buffer used to store the scaled values
var ElemCount : integer;
var i : integer;
PROCEDURE Init;
BEGIN
ArrayIn := CreateParam('Array In', PtArray, pioInput);
ArrayIn.Length(1);
SetArrayLength(Cache, 0); // initialize the dynamic buffer with zero items
END;
PROCEDURE Callback(N: integer);
BEGIN
IF (N = ArrayIn) THEN BEGIN
ElemCount := ArrayIn.Length; // read how many values are provided by the upstream module
SetArrayLength(Cache, ElemCount); // resize the dynamic buffer so it always fits the input array
FOR i := 0 TO ElemCount - 1 DO BEGIN
Cache[i] := ArrayIn.asArray(i); // simple processing: copy
END;
Trace(GetArrayLength(Cache)); // traces the size of the dynamic array
END;
END;
PROCEDURE Destroy;
BEGIN
SetArrayLength(Cache, 0);
END;
function GetArrayLength(A: dynamic-array): Integer;
Returns the size of a dynamic array declared in script code.
version 7.0.250121
Edit All Pages