Expression. An open-array constructor consists of one or more expressions separated by commas and enclosed in square brackets. Each expression must be assignment compatible with the element type of the open-array parameter. The use of an open- array constructor corresponds to creating a temporary array variable, and initializing the elements of the temporary array with the values given by the list of expressions. For example, given the declaration of the Sum function above, the statement X := Sum([A, 3.14159, B + C]); corresponds to Temp[0] := A; Temp[1] := 3.14159; Temp[2] := B + C; X := Sum(Temp); where Temp is a temporary array variable with three elements of type Double. A type variant open-array parameter allows an open array of expressions of varying types to be passed to a procedure or function. A type variant open-array parameter is declared using the syntax The array of const syntax is analogous to array of TVarRec. The TVarRec type is a variant record type which can represent values of integer, boolean, character, real, string, pointer, class, and class reference types. The TVarRec type is declared in the System unit as follows TVarRec = record case VType: Byte of vtInteger: (VInteger: Longint); vtBoolean: (VBoolean: Boolean); vtChar: (VChar: Char); vtExtended: (VExtended: PExtended); vtString: (VString: PString); vtPointer: (VPointer: Pointer); vtPChar: (VPChar: PChar); vtObject: (VObject: TObject); vtClass: (VClass: TClass); The VType field determines which value field is currently defined. Notice that for real or string values, the VExtended or VString field contains a pointer to the value rather than the value itself. The vtXXXX value type constants are also declared in the System unit: vtInteger = 0; vtBoolean = 1; vtChar = 2; vtExtended = 3; vtString = 4; vtPointer = 5; vtPChar = 6; vtObject = 7; vtClass = 8; The MakeStr function below takes a type variant open-array parameter and returns a string that is the concatenation of the string representations of the arguments. The AppendStr, IntToStr, FloatToStr, and StrPas functions used by MakeStr are defined in the SysUtils unit. function MakeStr(const Args: array of const): string; const BoolChars: array[Boolean] of Char = ('F', 'T');
Appears in 2 contracts
Sources: Copyright Agreement, Copyright Agreement