HP Business BASIC/XL Reference Manual - HP 3000 MPE/iX Computer Systems - Edition 1 (32715-90001)
3- 20
dex Start in the string, A$. If LEN(A$) = 0 then the value is a null
string. Otherwise, it is that string beginning at character index start
of A$ and ending at character index LEN(A$). (LEN is a function that
returns the length of a string. It is described in chapter 5.) If start
= (LEN(A$)+1) then the value is the null string.
Start Index and End Index or Length.
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 32770, inclusive.
Example
Consider the following two statements:
10 PRINT A$[Start,End]
20 PRINT A$[Start;Length]
Both statements reference the substring starting at the character at
index Start in the string, A$.
If End = (Start-1) or Length =0, then the value is the null string.
If Start = LEN(A$)+1), then the value is a string of (End-Start+1) or
Length spaces.
If End or (Start+Length-1) > MAXLEN(A$) then an error occurs.
For statement 10, if LEN(A$) >= End, then the value is the string
beginning at character index Start of A$ and ending at character index
End. Otherwise, the value is all of the characters from character index
Start of A$ until character index LEN(A$) with spaces appended to the end
of the value for a total of (End-Start+1) characters.
For statement 20, if LEN(A$) >= (Start+Length-1) then the value is the
string beginning at character index Start of A$ and ending at character
index (Start+Length-1). Otherwise, the value is all characters from
character index Start of A$ until character index LEN(A$) with spaces
appended to the end of the value for a total of Length characters.
10 A$="basic" !Substring values on the RHS of assignment