beautypg.com

Rpbasic-52 programming guide, String, Warning – Remote Processing BASIC 52 User Manual

Page 126

background image

RPBASIC-52 PROGRAMMING GUIDE

2-107

STRING

Syntax:

S T R I N G total bytes,string leng th
Where: total bytes = total num ber of bytes in m emory to allo cate

string leng th = maximum number of bytes in a string

Function:

Allocate memory for strings

Mode:

Comm and, run

Use:

STRING 56,10 : REM Allocate memory for 5 10-byte strings

Cards:

All

D E S C R IP T I ON

Prior to using strings, you m ust use STR ING to alloc ate mem ory for them. Th e STR ING argu ment valu es 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
t h en r ea l lo c a te d e ac h ti m e y ou u se t he S T R IN G o p e ra t or . S t ri n gs a re t er m i na t ed w i th a c ar r ia g e re t ur n (0 D H
or 13) which is the additional byte ad ded 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 num eric
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

M E M O R Y A L L O C A T I O N

Memory not allocated for strings

C - S T A C K

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)