Arrays
The Arrays group contains the embedded script-runtime operations for reading and changing array length, plus Velox helpers that copy strings between dynamic arrays and TStrings collections.
Use the length functions to create or resize a dynamic array before assigning indexed elements. Use the collection helpers when a Velox or Delphi object exposes a TStrings-compatible list but the mapping needs a TStringArray, or the reverse.
Common tasks
- Use
GetArrayLengthto read the number of elements in a static or dynamic array. - Use
SetArrayLengthto allocate, grow, shrink or clear a dynamic array. - Use
StringsToArrayto take a value-only snapshot of aTStringscollection. - Use
AddStringArrayToStringsto append array elements to an existingTStringListwithout clearing it.
Important behaviour
Array indexes are zero based. A length of N provides indexes from 0 through N - 1. Resizing preserves the common prefix, initialises new elements, and finalises elements removed from managed arrays.
The conversion helpers copy string values. They do not transfer ownership of the source collection, copy its associated Objects, or synchronise concurrent access.
Edge cases and quirks
GetArrayLengthsupports static and dynamic arrays, butSetArrayLengthresizes only dynamic arrays.- The effective Velox calls take parameters even though the generated declarations in the index omit them:
GetArrayLength(Arr)andSetArrayLength(Arr, Count). - In the shipped PascalScript runtime, a negative new array length is coerced to zero.
- Velox's
SetArrayLengthchanges one dimension per call and does not expose the broader string or multidimensional forms documented for Delphi and Free PascalSetLength. - Collection arguments must refer to live objects. The helpers do not check for
nilbefore dereferencing them.