Remote Processing CAMBASIC User Manual

Page 171

Advertising
background image

Comm ands - 138

Strings ar e stored in tw o ways. A literal str ing (e. g., A$ = "strin g") is stor ed in the pr ogram line in
which it appears. Other strings that are formed as a result of string operations (like concatenation)
are stored star ting at the top of RAM and build down towar ds the numer ic variables.

On pow er– up, you have 10 0 bytes of str ing space. You can c hange this w ith the CL EAR statement.
(Beneath the string area is the stack).

Thus, unused RA M extends from the top of the array space to the bottom of the stack.

EXAM PLE 1:

10 A = 1.1
20 B = VARPTR(A)
30 PRINT B ;
40 FOR X = 0 TO 3
50 PRINT PEEK(B+X) ;
60 NEXT : PRINT
RUN
17487 205 204 12 129

This examp le is for a simple num eric variable. The first num ber printed is the addr ess of the first
byte of the floating point representation of the number, or “1. 1”. This is the same as shown on the
previous page.

EXAM PLE 2:

10 H(0) = 1.1
20 Z = VARPTR(H(0))
30 PRINT Z
40 PRINT PEEK(Z) ; PEEK(Z+1) ; PEEK(Z+2) ; PEEK(Z+3)
RUN
17512
205 204 12 129

This ro utine retur ns the addr ess of the firs t element of arra y H. The next e lement, if present, would
be at address 17004, the next at 17008, and so forth.

EXAM PLE 3:

Addresses of array variables change each time a simple variable is assigned. For exam ple:

10 T(0) = 0
20 PRINT VARPTR(T(0))
30 W = 0
40 PRINT VARPTR(T(0))
RUN
17484
17490

In this example, the variable W is first used after the array address was printed. Thus the array
address is shifted by the six bytes required for a simple variable.

EXAM PLE 4:

10 A$ = "Tuesday"
20 R = VARPTR(A$)
30 PRINT CHR$(PEEK(R))
T

In this case, new variables are declared after VARPTR r eturned the address. Unlike the array case,

Advertising