Remote Processing CAMBASIC User Manual

Page 13

Advertising
background image

Concepts - 7

For example,

GOTOE

is not ok

EGOTO

is ok

String variables ar e limited to 255 charac ters. Arr ays may be any leng th, m ay be multidimensiona l, and include str ings.
String and array space is limited only by available memory.

Numer ic variables take seven bytes of memory. Two bytes for the name, one byte for the length and four bytes for the
value. String variables are stored w ith a 7– byte header and byte– for– byte as the string was assigned. The header and
string are stor ed in different locations.

String Variables
CAM BASIC reserve s 100 bytes for strings on power– up. U sing the CLEAR statement, mor e or less memor y may be
reserved. The reserved m emory is shared by all the strings. String constants do not use any of the reserved space. F or
example,

10 A$="This is a string constant"

does not use an y of the re served sp ace as the str ing is a constant.

In the example below , A $ and B$ do not use reser ved string space, but C$ does.

10 A$ = "Hello"
20 B$ = "there"
30 C$ = A$+B$

In this example, only B$ uses reserved space.

10 A$ = "Hello"
20 B$ = A$

Strings may be compared using the same relational operators that are used with numbers. The string operators are:

+

Adding or concatenating

=

equal

< >

not equal

>

greater than

<

less than

> =

greater than or equal

< =

less than or equal

C o n si de r th e fo ll ow i ng p r og r a m :

10 A$ = "ABC"
20 B$ = "ABD"
30 IF A$ > B$ THEN PRINT "YES" : ELSE PRINT "NO"
RUN
NO

Strings are compared on a char acter– by– character basis. In the exam ple above B$ is greater than A$, as the ASC II
v a lu e of D is g re a te r th a n t ha t o f C .

Advertising