Saving and linking programs chapter 3, Saving programs vs saving data, Commands – Remote Processing RPC-2350 User Manual

Page 19

Advertising
background image

SAVING AND LINKING PROGRAMS

CHAPTER 3

3-4

.
.
7000 IF A = 0 THEN 7100
.
.
7100

EXIT CLEAR

7110

LOAD 1 RUN

The above example shows how to link to another
program within a subroutine. If you do not use EXIT

CLEAR

, you will eventually end up with an <Out of

memory>

error.

Declare variables
All variables, dimensioned arrays, and string variables
should be declared in the first program. These variables
are accessible to both pr ogram s.

Program Re-entry
There is a good chance you will have declared a
dimensioned array or made room for strings in the
autorun progr am. If you do a C LEA R again, all
variables will be cleared.

What you m ust do when you enter a progra m is to test
for a re-entry flag at the start. If it is 0, then the
progr am know s to go and do va riable initializa tion. If it
is not 0, then it skips around it. For example:

10

IF FLAG <> 0 THEN 100

20

CLEAR 500

:’Clear space

30

DIM WEIGHT(100)

40

DIM B$(20)

.
.

More initialization code

.

100 FLAG = 1:’Signal initialized
110 ON ERR GOTO 10000
120 CONFIG COM$ 2,0,8,0,1
130 ON COM$ 2 GOSUB 2000

The code will not skip around the multitasking
statements when it is first Autorun. This is because, by
default, all Basic variables are reset to 0. When you link
progr ams, variables rem ain intact.

SAVING PROGRAMS VS SAVING DATA

A program number and F lash segment are related by the
following formula:

Flash segment = program number + 8

If you intend to save data to Flash, m ake sure you do not
write to a program area. P rograms are always saved
s ta r ti ng a t a d dr e ss 0 an d co n ti nu e un ti l e n d o f pr o g ra m .
Y o u c a n s a ve d at a a b ov e a p r o gr a m .

The important thing here is to remem ber that saving
program s to Flash and saving data to Flash are related.

COMMANDS

The following is a list of CAM BASIC commands used
for saving and loading pr ogram s.

Command

Function

LOAD

Transfers program from U3 to RAM
for editing or running.

L O A D n

Transfers pr ogram of specified area of
U 3 to RA M .

L O A D data

Multi-part syntax command that
moves data from F lash to RAM or
RAM to RAM. Refer to Chapter 5 or
the CAMBASIC manual for more
information.

SAVE

Saves a program fr om RAM to U3 for
Autorun

SAVE n

Save a program fr om RAM to a
program area of Flash.

SAVE data

Multi-part syntax command that saves
data from RAM to Flash. Refer to
Chapter 5 or the CAMBASIC manual
for more inform ation

Advertising