
RPBASIC-52 PROGRAMMING GUIDE
2-107
STRING
Syntax: STRING total bytes,string length
Where: total bytes = total num ber of bytes in m emory to allocate
string length = maximum number of bytes in a string
Function: Allocate memory for strings
Mode: Command, run
Use: STRING 56,10 : REM Allocate memory for 5 10-byte strings
Cards: All
DESCRIPTION
Prior to using strings, you m ust use STR ING to allocate mem ory for them. The STRING argument values are
computed by this equation:
total bytes = ((string leng th + 1) * number_of_strings) +1
The only way to recover string memory is with a "STRING 0,0" instruction. String memory is reclaimed and
then reallocated each time you use the STRING operator. Strings are terminated with a carriage return (0DH
or 13) which is the additional byte added to your bytes per string expr.
WARNING:
STRIN G causes RPB ASIC-5 2 to execute the equivalent of a C LEA R instruction sinc e string and numeric
variables occupy the same m emory space. In other words, the STR ING instruction clears all variables,
interrupts and stacks. Allocate string memory early in your program and don't reallocate it unless you can
accept the loss of all variables.
RELATED
ASC, CHR, STR
ERRORS
MEMORY ALLOCATION Memory not allocated for strings
C-STACK STRING used in a subroutine, clearing the stack.
EXAMPLES
10 STRING 1000,40
20 $(0) = "Up to 40 characters in this string"
.
.
100 $(2) = COM$(1)
Komentáře k této Příručce