HP Pascal/iX Reference Manual (31502-90022)

9- 10
strwrite
Usage
strwrite
(s, p, t, e)
strwrite
(s, p, t, e1,...,en)
Parameters
s
A string variable.
p
An integer expression.
t
An integer or integer subrange variable.
e
A simple or string expression, or a PAC variable. Any number
of
e
parameters may appear separated by commas.
Description
The procedure strwrite
(s, p, t, e)
writes the value of
e
on
s
starting at
s [ p ]
. After the operation, the value of the variable appearing as
the
t
parameter is the index of the component of
s
, immediately after the
last component of
s
that strwrite has accessed.
S
is treated as a single-line textfile. Strwrite
(s, p, t, e)
is
analogous to write
(f, e)
when
f
is a one-line textfile. As with write,
strwrite also permits you to format the value of
e
as it is written to
s
using the formatting conventions. The same default formatting values
hold for strwrite.
Strwrite may write into the middle of a string without affecting the
original length. It is an error if strwrite attempts to write beyond the
maximum length of
s
, or if
p
is greater than strlen
(s)
+ 1. The current
length of
s
is updated if the current length is increased.
Example
VAR
s: string[80];
p,t: 1..80;
f,g: integer;
BEGIN
f:= 100;
g:= 99;
p:=1;
s:=''; { empty string }
.
strwrite(s,p,t,f:3); { S is now '100'; t is 4 }
strwrite(s,t,t,' ',g:2); { S is now '100 99'; t is 7. }
.
END.
String Functions
String functions
may be used to manipulate string expressions, variables,
or literals. A string expression may consist of a string literal, a
string variable, a string constant, a function result that is a string,
or an expression formed with the concatenation operator.
Note that strings must be initialized just like any other variable. The
string functions and procedures assume that the string parameters contain
valid information. The string functions str, strlen, strltrim, strmax,
strpos, strrpt, or strrtrim, are defined by HP Pascal and are described
on subsequent pages.