Chapter 2 setup and operation – Remote Processing RPC-2350 User Manual

Page 13

Advertising
background image

CHAPTER 2

SETUP AND OPERATION

2-7

You can wr ite a program in lower case cha racters.
CAM BASIC translates them to upper case.

Some program mers put "N EW" as the first line in the
file. During debugging, it is common to insert
"temporary" lines. Adding NEW ensures that these lines
are gon e. D ownloadin g time is incr eased wh en the old
progr am is still pre sent.

Instead of uploading and downloading programs, you can
save them to the on car d Flash E PRO M. This is useful if
you are using a terminal to write programs. Make sure
the 'A utorun' jumper is installed (See Chapter 3
S A V IN G P R O GR A M S
). To prevent automatic program
execution on power up, inser t the STOP statement at the
beginning of the program (such as line 1). When you
power up the RP C-2350 , the progr am is tra nsferr ed into
RAM and executed. Delete the progr am line with the
STOP statement to norm ally start progr ams.

Writing with line numbers
You can manually enter line nu mber s. T he prob lem is
when you have to add another line. It is quite common
for program s to grow and run out of line numbers. You
can execute the RE RUM comma nd to renum ber lines.

A technique used to further program documentation and
reduce code space is the use of comments in a
downloaded file. For example, you could have the
following in a file written on your editor:

'Check VAT temperature
'Read the output from the RTD and
' calculate the temperature

2200 a = ain(0) :'Get temp

The first 3 comments downloaded to the RPC -2350
are ignored. Similarly, the empty lines between
comm ents are a lso ignored . L ine 2200, with its
comment, is a part of the program and could be listed.
The m ajor pena lty by wr iting a progr am this w ay is
increased download time.

NOTE: Some ve rsions of P C Sm artLin k may op tionally

strip comments before downloading. Check
your manual to see if this option is available.

If you like to write programs in separate modules, you
can download them separately. M odules are assigned
b lo c ks o f l in e nu m b er s . S ta r t u p co d e m i gh t b e fr o m 1
to 999. Interrupt handling (keypad, serial ports) might
be from lines 1000 to 1499. Display output might be

from 1500 to 2500. The program mer m ust determine
the number of lines required for each section.

W h e n r e p la c in g a p r o gr a m or s ec t io n , do w n lo a di ng ti m e
is increased. Blocks of line numbers cannot be
renumber ed by CAM BASIC when other par ts of the
program are installed. However , if a particular section
is the only program downloaded, then line renumbering
in that range is possible. Refer to the CAM BASIC
RENU M comm and.

CAM BASIC automatically formats a line for minimum
code space and increased readability. For example, you
could download the following line of code:

10 fora=0to5

When you listed this line, it would appear as:

10 FOR A = 0 TO 5

Spaces are initially displayed but not stored. The
following line:

10 for a = 0 to 5

would be compressed and displayed as in the second
example above. Spaces ar e removed.

Writing without line numbers
Many progr amming languages such as C and versions of
BASIC and do not use line numbers. CA MBASIC uses
line numbers simply because you can edit them through a
serial ter minal.

You can write and edit CAM BASIC progr ams without
using line num bers. This ma kes for m uch mor e reada ble
code.

T h e de m o pr o g ra m N O L IN E S . B AS is su c h a p r og r a m .
(Other program demos may also not use line numbers. )
The key is to use the AUTO com mand. This command
automatic ally assigns a num ber to eac h progr am line as it
is entered.

There are a few things you have to keep in mind.

1. Put the N EW statement at the start of the
program file. This removes old code.

2. You must use the remark statement (') in lines
that do not have any code. This is because AUTO

Advertising