Download AMOS AlphaPascal
Transcript
STRING AND CHARACTER ARRAY FUNCTIONS. AND PROCEDURES
Page 13—9
and:
ever ever ever too long
MOVERIGHT and MOVELEFT
can produce radically different results, depending on
You must be careful to choose the correct MOVE
function for yourparticutar application.
the
data
13.2.3
you
give
them.
SCAN
The SCAN function returns the number of characters In the array from the
beginning of the array until the specified character. (If the specified
characters are not found, SCAN returns the number of characters in the
entire array.) The function invocation takes this form:
SCAN (Length,Partial—expression,Source—array);
Length gives the length of
packed array of type CHAR that is to
takes the form:
where
the array, Source—array specified the
be
searched,
and
Partial—expression
<> character—expression
or:
= character—expression
For example:
PROGRAM Test5can;
VAR
Source
:
PACKED ARRAY C1..25] OF CHAR;
BEGIN C TestScan )
Source := 'Error:30240 type RETURN
';
WRITELN('Error code starts after char #: ',SCAN(25,=':',Source))
END C TestScan 3.
If
the
searched
for character—expression
array, SCAN returns a zero.
By specifying a negative length,
backward, from right to left.
array, SCAN
Is
the first character of the
can tell SCAN to scan the array
If the specified character appears in the
you
then returns a negative number specifying the number of
characters scanned from the right of the array before the specified
character was reached. If you supply a negative length, be sure to also
specify the position in the array at which you wish the search to start.
For example:
WRITELN('zt starts after character #',SCAN(—25,=':',Source(25]));