# INS

Updated: 10/19/2021, 9:29:48 PM
Created: 10/19/2021, 9:29:48 PM
Last Updated By: Kevin Munoz
Read Time: 1 minute(s)

Tags: dynamic array

# Description

The INS statement allows the insertion of elements into a dynamic array.

INS expression BEFORE Var<expression1{, expression2{, expression3}}>
1

Where:

  • expression evaluates to the element to be inserted in the dynamic array.
  • expression1expression2 and expression3 should all evaluate to numeric values and specify the Field, Value and Sub-Value before which the new element is to be inserted.

# Note

Specifying a negative value to any of the expressions 1 through 3 will cause the element to append as the last Field, Value or Sub-Value rather than at a specific position. Only one expression may be negative otherwise only the first negative value is used correctly while the others are treated as the value 1.

The statement will insert NULL Fields, Values or Sub-Values accordingly if any of the specified insertion points exceeds the number currently existing.

An example of use is as:

Values = ''
FOR index = 1 TO 50
    INS index BEFORE Values<-1>
NEXT I
1
2
3
4

or

FOR index = 2 TO 12
    INS index * 7 BEFORE Values<7, index>
NEXT I
1
2
3

to populate the respective arrays with values.

Go back to jBASE BASIC

Go back to Programmers' Reference Guide