INSA |
Insa is used to enter 'empty' elements from single-sized tables, from a given index.
Insa start [ , number [ , limit ] ] liste_nom_var
|
Element |
Description |
Restrictions |
|
start |
Integer numerical expression of the index in the tables from which the insertion is made |
The start should: |
|
number |
Integer numerical expression of the number of elements to be inserted. |
number > 0 |
|
limit |
Integer numerical expression of the index in the tables where insertion ends. |
The limit should not exceed the smallest of the upper limits of the tables. |
|
liste_nom_var |
List ofnom_var separated by the character ','. |
None. |
|
nom_var |
nom_de_variable indicating the table in which the insertion has been made. For a scrolling table, this is the variable for the foot of the table. |
None. |
# Reading the first N records of the CLIENT file and
# insertion of names and keys (in the
order of the names in 2 tables.
# The MAX variable indicates the position
of the last elements in the tables
Local File CLIENT
Char NOM (20) (N), CLE (4) (N)
Local Shortint I, MAX : MAX = 0
# (Rest of previous example)
Read [CLI]CODCLE First
While MAX < dim(NOM) & fstat = 0
:# end of table or file
I = 0
While NOM(I)
<> "" & [F]NOM > NOM(I) : I += 1 : Wend
If NOM(I)
<> ""
Insa I, 1 NOM, CLE
Endif
NOM(I) = [F]NOM
CLE(I) = [F]CLE
MAX
+= 1
Read
[CLI]CODCLE Next
Wend
# Insertion of rows from a scrolling
table (whose foot of table variable
# is called NLI) according to variable
parameters.
Insa [V]DEB, [V]NB, [V]FIN
[M]NLI
# There are two tables of elements (taken
from a set of texts giving
# names of terminal drivers). One (NOM)
includes names of
# files, the other (CAR) their
"associated" characters:
|
|
0 |
1 |
2 |
3 |
4 |
5 |
... |
|
CAR |
A |
A |
H |
I |
V |
V |
... |
|
NAME |
ansi |
at386 |
hp |
ibm3151 |
vt200 |
vt220 |
... |
# Assume that 2 elements in the 3rd position
are to be inserted
# (thus in level 2):
Insa 2, 2 CAR, NOM
# The result of this instruction will be:
|
|
0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
... |
|
CAR |
A |
A |
|
|
H |
I |
V |
V |
... |
|
NAME |
ansi |
at386 |
|
|
hp |
ibm3151 |
vt200 |
vt220 |
... |
# Now assume that the limit has a value less than
# the number of elements in the
tables :
|
|
0 |
1 |
2 |
3 |
4 |
5 |
... |
|
CAR |
A |
A |
|
|
H |
V |
... |
|
NAME |
ansi |
at386 |
|
|
hp |
vt220 |
... |
#
elements I, ibm3151 and V, vt200 "are lost"
#
and those above the limit: V, vt220 are retained
Insa is used to insert 'empty' elements (default 1) in a set of single-sized tables. The value of these elements is zero (value 0, null date or empty string) and are not initialised for a scrolling table. In the instruction's syntax, start establishes the index (shared by all the tables) where the insertion starts, and number indicates the number of elements to be inserted.
For each table, the elements are shifted from 'start' by a number of positions equal to 'number'. The last elements 'number' of the table are reset to zero (the default 'limit' is the end of the table).
Giving a value to 'limit' that is less than the smallest of the lower limits of the tables (a higher value would not make sense) means that the table is to be restricted. In this case, the elements 'number' placed just before 'limit' is lost, the elements before 'start' and after 'limit' are unchanged. The following drawing simulates insertion of 'number' positions from a table of elements, D indicating 'start' and B 'limit' (note that the index element 'limit' is lost):
|
|
|
D |
Lost B |
|
|||||||||||||
|
Before |
I |
I |
... |
I |
D |
D |
... |
D |
D |
P |
P |
... |
P |
I |
I |
... |
I |
|
After |
I |
I |
... |
I |
|
|
... |
|
D |
D |
... |
D |
D |
I |
I |
... |
I |
|
|
Unchanged |
Number |
Shifted |
Unchanged |
|||||||||||||
When an insertion is made in a scrolling table, the variable name given is that of the variable for the foot of the table; it then indicates all the variables in the scrolling table.
Where rows are inserted in a scrolling table, the foot of table variable is not updated.
|
Error |
Description |
|
ERMODE (10) |
start, number or limit are not numerical. |
|
ERINDI ( 8) |
One of the indices is outside the limits of one of the tables. |
|
ERDOM (50) |
nombre <= 0. |
|
ERDIM (55) |
One of the variables is not single-sized. |
|
|