xHarbour Reference Documentation > Operator Reference |
Array element operator (unary): retrieves array elements.
<aArray>[<nSubScript,...>] <aArray>[<nSubScript1>][nSubScript2][<...>]
The array element operator retrieves a value stored in an array element. The ordinal position of the desired element must be specified as a numeric value. Elements of multi-dimensional arrays are specified using one subscript value per array dimension.
Note: if <nSubScript> is a negative value, the operator retrieves the element Abs(<nSubScript>) from the end of the array.
See also: | [ ] (string), { }, Array() |
Category: | Operators , Special operators |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
// The example shows some variations of the use of the subscript operator. PROCEDURE Main LOCAL aArray := { "One", "Two", "Three" } // one dimensional array ? aArray[1] // result: One ? aArray[2] // result: Two ? aArray[3] // result: Three ? aArray[-1] // result: Three ? aArray[-3] // result: One USE Customer // two dimensional array // combined with function call ? DbStruct()[1,1] // result: FIRSTNAME RETURN
http://www.xHarbour.com