FutureBasic Logo

<<    Index    >> FutureBasic

index$ I   statement



Syntax
index$ i (element [,indexID]) = stringExpr

Description
This statement inserts a new element into one of the special index$ string arrays, and assigns the value of stringExpr to the new element (see the index$ statement and the clear <index> statement for information about how index$ arrays are created). The indexID parameter specifies which of the index$ arrays (0 through 9) to insert an element into; if this parameter is omitted, index$ array 0 is used. The element parameter specifies where in the array to insert the string.
Unlike the index$ statement, the index$ i statement does not merely replace the contents of the indicated element. Instead, all of the strings at position element and beyond are moved in memory, to open a space in which to insert the new string. As shown in the diagram, this also affect the element numbers by which the moved strings are identified.
This statement is the complement of index$ d, which deletes an element from the array.

Example
This illustrates the difference between inserting an element using index$ i, and replacing an element using the index$ statement.

index$ i(5) = "Riley"
element #contents
4Sandy
5Joshua
6Carrie
element #contents
4Sandy
5Riley
6Joshua
7Carrie
Before After


index$(5) = "Riley"
element #contents
4Sandy
5Joshua
6Carrie
element #contents
4Sandy
5Riley
6Carrie
Before After

See also
CFIndexSort; clear <index>; index$ D; index$ function; index$ statement; indexf; mem