MyChat Scripts GetArrayLength, get the size of the dynamic array
Getting the size of the one-dimensional dynamic array.
Syntax
function GetArrayLength(Arr: <dynamic array>): integer;
Parameters and return values
Parameter |
Type |
Value |
Arr |
array of... |
one-dimensional dynamic array of any type. |
Function result
A number of array elements. If 0 the array is empty. The numeration of the array elements starts from 0, and the first element has a zero index.
Example
var
ArrData: array of integer;
i, iLength: integer;
begin
SetArrayLength(ArrData, random(5) + 5);
iLength := GetArrayLength(ArrData);
for i := 0 to iLength - 1 do
ArrData[i] := 100 + random(100);
mLogScript('Array length: ' + IntToStr(iLength) + ' elements', '');
for i := 0 to iLength - 1 do
mLogScript(IntToStr(i + 1) + ': ' + IntToStr(ArrData[i]), '');
end.
Script work result
[13:37:12] (Log "GetArrayLength"): Array length: 8 elements
[13:37:12] (Log "GetArrayLength"): 1: 193
[13:37:12] (Log "GetArrayLength"): 2: 188
[13:37:12] (Log "GetArrayLength"): 3: 144
[13:37:12] (Log "GetArrayLength"): 4: 113
[13:37:12] (Log "GetArrayLength"): 5: 125
[13:37:12] (Log "GetArrayLength"): 6: 133
[13:37:12] (Log "GetArrayLength"): 7: 150
[13:37:12] (Log "GetArrayLength"): 8: 197
[13:37:12] (Run "GetArrayLength"): Script operation time: 7 ms
[13:37:12] (Run "GetArrayLength"): Script done successfully.