Remote-processing RPC-2350 Manuale Utente Pagina 13

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 83
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti
Vedere la pagina 12
CHAPTER 2 SETUP AND OPERATION
2-7
You can wr ite a program in lower case characters.
CAMBASIC 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 gone. D ownloading time is incr eased when the old
program is still pre sent.
Instead of uploading and downloading programs, you can
save them to the on card Flash E PRO M. This is useful if
you are using a terminal to write programs. Make sure
the 'Autorun' jumper is installed (See Chapter 3
SAVING PROGRAMS). To prevent automatic program
execution on power up, insert 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 transferr ed into
RAM and executed. Delete the program line with the
STOP statement to norm ally start programs.
Writing with line numbers
You can manually enter line nu mbers. T he problem is
when you have to add another line. It is quite common
for programs to grow and run out of line numbers. You
can execute the RERUM command to renumber 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 . Line 2200, with its
comment, is a part of the program and could be listed.
The major pena lty by wr iting a progr am this way 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. Modules are assigned
blocks of line numbers. Start up code might be from 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.
When replacing a program or section, downloading time
is increased. Blocks of line numbers cannot be
renumbered by CAMBASIC 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 CAMBASIC
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 are removed.
Writing without line numbers
Many programming languages such as C and versions of
BASIC and do not use line numbers. CAMBASIC uses
line numbers simply because you can edit them through a
serial terminal.
You can write and edit CAM BASIC programs without
using line numbers. This makes for m uch mor e readable
code.
The demo program NOLINES.BAS is such a program.
(Other program demos may also not use line numbers.)
The key is to use the AUTO com mand. This command
automatically 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 NEW 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
Vedere la pagina 12
1 2 ... 8 9 10 11 12 13 14 15 16 17 18 ... 82 83

Commenti su questo manuale

Nessun commento