stringfunclib
The functions of this library take strings apart and build new ones:
Left$, Right$ and Mid$ cut out parts, Instr and Replace$
search, UCase$ and LCase$ change the case, LSet$, RSet$ and
Centre$ pad to a width, and Hex$, Bin$, Chr$ and Asc convert
between numbers and characters. Mki$, Mkl$ and Mkq$ turn a number
into its bytes, and Cvi, Cvl and Cvq read them back, for example
to write numbers into a file or read them from one.
Positions count from 1. A length or count below 0 counts as 0, and a
length beyond the end of a string takes the string to its end. Searches
and replacements compare upper and lower case as different unless
CaseSense Off is set; the case of the letters a to z only is
changed or ignored.
Library number 185.
Commands
Asc
The code of the first character of the string, or -1 for the empty string.
Function, result .w. Help text: (String$)
Arguments: $
Bin$
The value as 32 binary digits.
Function, result $. Help text: (Expression)
Arguments: .l
CaseSense
CaseSense On makes Instr and Replace$ tell upper and lower case apart, as they do at the start of a program; CaseSense Off makes them ignore the case of a to z.
Statement. Help text: On|Off
Arguments: .w
Centre$
String$ centred in a field of Characters characters, with spaces on both sides; of a longer string the middle characters.
Function, result $. Help text: (String$,Characters)
Arguments: $, .l
Chr$
A string of one character, the one with the given code.
Function, result $. Help text: (Expression)
Arguments: .w
Cvi
The first two bytes of the string as a word; the reverse of Mki$.
Function, result .w. Help text: (String$)
Arguments: $
A shorter string counts its missing bytes as 0: Cvi("a") is $6100. With
runtime error checking, a string shorter than 2 characters is the
error “Cvi needs a String of at least 2 Characters”.
Cvl
The first four bytes of the string as a long; the reverse of Mkl$.
Function, result .l. Help text: (String$)
Arguments: $
A shorter string counts its missing bytes as 0: Cvl("ab") is
$61620000. With runtime error checking, a string shorter than 4
characters is the error “Cvl needs a String of at least 4 Characters”.
Cvq
The first four bytes of the string as a quick value; the reverse of Mkq$.
Function, result .q. Help text: (String$)
Arguments: $
A shorter string counts its missing bytes as 0. With runtime error checking, a string shorter than 4 characters is the error “Cvq needs a String of at least 4 Characters”.
Hex$
The value as eight hexadecimal digits, in upper case.
Function, result $. Help text: (Expression)
Arguments: .l
Instr
The position of Findstring$ in String$, searching from the first character or from Startpos; 0 if it is not found.
Function, result .l. Help text: (String$,Findstring$[,Startpos])
2 forms:
$, $$, $, .l
A Startpos of 0 or less searches from the first character, and one
behind the end of String$ gives 0. With runtime error checking, a
Startpos below 1 is the error “Instr Startpos MUST be greater than
zero”.
LCase$
The string with the letters A to Z in lower case.
Function, result $. Help text: (String$)
Arguments: $
Left$
The first Length characters of String$.
Function, result $. Help text: (String$,Length)
Arguments: $, .l
Len
The number of characters in the string.
Function, result .l. Help text: (String$)
Arguments: $
LSet$
String$ in a field of Characters characters, left aligned: filled with spaces at the end, or cut to that length.
Function, result $. Help text: (String$,Characters)
Arguments: $, .l
Mid$
The characters of String$ from position Startchar on, Length of them or, without Length, all to the end. A start beyond the end gives the empty string.
Function, result $. Help text: (String$,Startchar[,Length])
2 forms:
$, .l, .l$, .l
A Length beyond the end of the string stops at its end.
Mki$
The low word of the value as a string of two bytes, the high byte first.
Function, result $. Help text: (Integer)
Arguments: .l
Mkl$
The long value as a string of four bytes, the high byte first.
Function, result $. Help text: (Long)
Arguments: .l
Mkq$
The quick value as a string of four bytes, the high byte first.
Function, result $. Help text: (Quick)
Arguments: .q
Replace$
String$ with every occurrence of Findstring$ replaced by Replacestring$.
Function, result $. Help text: (String$,Findstring$,Replacestring$)
Arguments: $, $, $
With an empty Findstring$ the string comes back unchanged.
Right$
The last Length characters of String$.
Function, result $. Help text: (String$,Length)
Arguments: $, .l
RSet$
String$ in a field of Characters characters, right aligned: spaces in front, or only its last characters if it is longer.
Function, result $. Help text: (String$,Characters)
Arguments: $, .l
String$
Repeats copies of String$ joined together; a count of 0 or less gives the empty string.
Function, result $. Help text: (String$,Repeats)
Arguments: $, .l
StripLead$
String$ without the characters with the code Ascii at its start.
Function, result $. Help text: (String$,Ascii)
Arguments: $, .w
StripTrail$
String$ without the characters with the code Ascii at its end.
Function, result $. Help text: (String$,Ascii)
Arguments: $, .w
UCase$
The string with the letters a to z in upper case.
Function, result $. Help text: (String$)
Arguments: $
UnLeft$
String$ without its last Length characters.
Function, result $. Help text: (String$,Length)
Arguments: $, .l
UnRight$
String$ without its first Length characters.
Function, result $. Help text: (String$,Length)
Arguments: $, .l