An array slice can
be
used
to
specify a source or a destination subarray for
an
assignment
statement
•
•
(single elementj
Irange of elements)
(range
to
end]
[range from beglnnlngl
PRINT
data
array
PRINT
letters$(1
TO
15)
PRINT
two_d_array
(3)
(2
TO
4)
index: =
numeric_exp
numerlc_exp
TO
numerlc_exp
numerlc_exp
TO
TO
numeric_express/on
array_reference:
= I variable
I varlabfe ( [mdex * [,mdexj *i )
I
II,
III.
Under certain Circumstances
It
IS
possible to refer
to
more than one element
in
an array
i.e slice the
array.
The array slice can be thought of as defining a subarray or a series
of
subarrays to SuperBASIC Each slice can define a continuous sequence
of
elements
belonging
to
a particular dimension
of
the ollginal array The term array
In
thiS
context
can include a
numellc
array,
a stllng array or a simple stllng.
It
is
not necessary
to
specify an index for the
full
number
of
dimensions
of
an array.
If
a dimension
IS
omitted then slices are added which
will
select the
full
range
of
elements
for that particular dimension,
i,e,
the slice
(0
TO
).
SuperBASIC can only add slices to
the end
of
a
liSt
of
array indices.
syntax:
example:
slicing
will select the nth character.
Will
select
all
characters from the nth
to
the mth,
inclUSively.
will
select from a character n to the end, inclUSively
will
select from the beginning to the nth character,
inclusively,
will
select the entire contents
01
a
a$
a$(n TO)
a$(1
TO
m)
a$
Stllng slicing
IS
performed
in
the same way as
sliCing
numeric or stllng arrays.
Thus
a$(n)
a$(n
TO
m)
Some forms of BASIC have functions called LEFT$, MID$, RIGHT$, These are not
necessary
in
SuperBASIC Their eqUivalents are specified below:
SuperBASIC
a$(n)
a$(n
TO
m)
a$(1
TO
n)
a$(n TO)
Other BASIC
MID$ (a$,n,1)
MID$
(a$,n,m+1-n)
LEFT$ (a$,n)
RIGHT$
(a$,LEN(a$)+1-n)
•
warning
Assigning data to a sliced stllng array or string vallable may not have the deslled effect
Assignments made
in
this way
will
not update the length of the stllng. The length of
a string array or
stllng variable
is
only updated when
an
assignment
is
made to the
whole string.
•
46
12'S4