basic.insert

Function/BASIC Program, Releases: AP and R83

Inserts element into array.

Syntax

insert(dynamic.array.expression, ac.expression; string.expression) insert(dynamic.array.expression, ac.expression, vc.expression; string.expression) insert(dynamic.array.expression, ac.expression, vc.expression, sc.expression, string.expression)

Description

inserts the element referenced by 'string.expression' into a specific attribute, value, or subvalue location in 'dynamic.array.expression'.

'-1' may be specified as the 'ac.expression', 'vc.expression', or 'sc.expression'. Position '-1' inserts the expression as the 'last' element in the respective location.

'0' (zero) may be specified as the 'ac.expression'. Position '0' inserts the expression as the 'first' attribute. A '0' as the 'vc.expression', or the 'sc.expression' is ignored.

Unlike the 'replace' function, which changes the contents of a dynamic array element without changing the logical position of it or any other element, the 'insert' function inserts the results of 'string.expression' at the specified location and all following information at that dynamic array level (attribute, value, or subvalue) is shifted one position higher in the array. If an 'ac.expression' of 1 is specified, the expression is inserted before attribute 1, shifting attribute 1 to attribute 2.

The 'insert', 'replace' and 'delete' functions force the entire dynamic array (string) to be rebuilt. See 'dynamic array'.

Example

customer.item = insert(customer.item,1,1,0,name)
-or-
customer.item = insert(customer.item,1,1;name)

Both of these examples are axactly the same. They insert the current value of
'name' in attribute 1 (one) of the array, 'customer.item'.
Every other value in attribute 1 'shifts right' by one position.
(Value 1 becomes value 2, and so on.) The values of attribute one are shifted,
but the other attributes in the item maintain their relative position.

See Also

Command Name Type Description
basic.statements Definition Definition of statements and functions.
basic.locate Statement Locates element in string expression.
basic.array.dynamic Definition A string variable delimited by reserved metacharacters.
basic.array.references Definition Referencing arrays.
basic.delete.function Function Deletes element from array.
basic.ac.expression Definition Derives an attribute count.
basic.del Statement Alternate method of 'delete'.
basic.vc.expression Definition Derives a value count.
string.expressions Definition A string of characters.
basic.ins Statement Alternate method of 'insert'.
basic.assignment Definition Assigns value to variable.
basic.extract Function Extracts element from array.
basic.replace Function Replaces element in string expression.
basic.array.variable Definition References a dimensioned array.
basic.functions Definition elements in FlashBASIC or Pick/BASIC language expressions, returning a single value in place, as a function of the arguments. A function can be used anywhere a variable or expression is used.
basic.sc.expression Definition Derives a subvalue count.

User Comments

What do you think?

Share your experience or ask a question by using the form below.

Login to leave your comments.