HP Business BASIC/XL Reference Manual - HP 3000 MPE/iX Computer Systems - Edition 1 (32715-90001)

3- 22
Syntax
str_var
[
start
,
end
]
str_var
[
start
;
length
]
Parameters
str_var
A valid string variable name or string variable array
element reference.
start
A numeric literal or expression that evaluates to a
value between 1 and LEN(
str_var
)+1, inclusive.
end
A numeric literal or expression that evaluates to a
value between
start
-1 and 32767, inclusive.
length
A numeric literal or expression that evaluates to a
value between 0- and 32767, inclusive.
Example
Consider the following two assignment statements:
10 A$[Start,End]=B$
20 A$[Start;Length]=B$
Execution of either of these statements assigns the value of B$ to A$
beginning at character Start.
If Start = (LEN(A$)+1) then a string append is done.
If the LEN of the string after the assignment is greater than that before
assignment then the actual length of A$ is reset.
If LEN(B$) >= (End-Start+1) or Length then the number of characters from
B$ assigned to A$ is equal to (End-Start+1) or Length, respectively. If
LEN(B$) < (End-Start+1) or Length, then the value of B$ is assigned to A$
beginning at character position Start. Spaces assigned to each remain-
ing character in A$ up to and including the character with index End or
until a total of Length characters has been assigned.
If End or (Start+Length-1) > MAXLEN(A$), then a bounds violation occurs.
10 B$="basic" !Assigns a value to B$
20 A$[1]=B$ !Value of A$ is "basic"
30 A$[2,6]=B$ !Value of A$ is now "bbasic"
40 A$[1;5]=B$ !Value of A$ is now "basicc"
50 A$[4,6]=B$ !Value of A$ is now "basbas"
60 A$[7]=B$ !Value of A$ is "basbasbasic" - string append
70 A$[1,6]=B$ !Value of A$ is "basic basic" - 1 space was assigned
80 A$[13;5]=B$ !Range error because 13 &> LNE(A$)+1
90 A$[LEN(A$)+1]=B$ !Value of A$ is "basic basicbasic" - string append
Expressions
An expression is an operator with its operands or a function call. HP
Business BASIC/XL evaluates an expression and returns a result.