Strings
Syntax
DIM symbolname$ ( maxlength )
Description
A STRING is an array of characters, and is limited to 256 characters. Despite the use of the maxlength , an implicit CHR (0) is added to the end of the STRING, to allow for variable length during program execution. STRINGs are not checked for length at run time, so care must be taken to avoid filling it beyond the declared DIM. String variable names must end in a dollar sign.
Individual characters within a string can be accessed like an array, such as a$(12) returns the character in position 12, starting from 0.
Example
' Fixed-length declaration, but value varies during
execution
DIM a$ (20)
a$ =
"Hello"
a$ = a$+chr(32)+ "World"
PRINT
a$ ' = "Hello World"
Differences from other BASICs
- Similar to Visual BASIC strings. String$ names allowed in Visual BASIC, but $ not enforced. Also strings can have implied length when declared, but ARMbasic requires an explicit length when declared.
- PBASIC has Arrays of BYTEs but no specific strings