06.05.2013 Views

Amiga Computing - Commodore Is Awesome

Amiga Computing - Commodore Is Awesome

Amiga Computing - Commodore Is Awesome

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Paul Overaa explains<br />

how AlRexxis<br />

de-bugging facilities<br />

an be used to<br />

find errors in scripts<br />

ebugging and testing con be one of the<br />

most time-consuming stages of any software<br />

development, and ARexx scripts<br />

ore, of course, no exception to this. The<br />

use of proper structured design techniques, modular<br />

programming, topdown development and so on<br />

titips, but it will not eliminate all the problems. No<br />

Tatter how conscientious a programmer you ore,<br />

some mistakes are bound to be made.<br />

Sometimes problems will be due to simple syntax<br />

!tors caused by, say, a basic misunderstanding of<br />

ow a statement should be written, or a dyslexic<br />

slip at the keyboard - inadvertently writing Uppre(l<br />

when you meant Upper( for example, or writing a<br />

s<br />

ebecause<br />

you didn't hit the shift key at the right time.<br />

mSuch<br />

mistakes ore usually considered harmless<br />

because they are easily found and therefore easily<br />

i orrected.<br />

- ARexx is very good in this respect and not<br />

conly<br />

will it identify most errors but you con be fairly<br />

oSure<br />

that any ARexx program which gets to a<br />

l noble stage is going to be nigh on 100 per cent<br />

ontacticaly<br />

correct.<br />

If, whilst developing a script, you get past the<br />

n<br />

ol syntax error stage and your program seems<br />

wrun<br />

in some fashion, then often you will be home<br />

hnd<br />

dry. Occasionally, however, things will go<br />

e ong - o program may run to a point arid then for<br />

n a obvious reason moy lust fail to behave as<br />

expected. It's at this stage that we enter the realm<br />

y<br />

debugging proper and one of the most important<br />

o<br />

s available to the modern programmer is easily<br />

u ble trace facilities.<br />

mARexx<br />

supports two basic modes of tracing:<br />

e sly, there is the normal Or 'non-interactive ' troc•<br />

amg<br />

mode which simply alows troce information to<br />

viewed Secondly, there is on 'interactive' mode<br />

n<br />

hich allows the programmer to step through the<br />

t °gram and interact with it as the trace proceeds<br />

ttea<br />

sidin or sterr if available'. It is possible to look<br />

o at the contents of variables, re-execute clauses, and<br />

weven<br />

type in instructions which are subsequently<br />

r xecuted as though they were o part of the<br />

ogram itself.<br />

i<br />

t<br />

HU, ttiLim• •<br />

AO C DONIPLIMINel• •<br />

e<br />

,<br />

.<br />

••• a<br />

.<br />

• • •<br />

. ••••• • • • • • I—•<br />

Not •_<br />

1<br />

••••<br />

c<br />

•<br />

be.<br />

o<br />

l<br />

IIIMM...e,agm/O h• • •<br />

o<br />

I<br />

l<br />

• n<br />

0<br />

1<br />

0<br />

1<br />

4<br />

1<br />

1<br />

0<br />

•<br />

•<br />

•<br />

•<br />

•<br />

•<br />

N<br />

.<br />

1<br />

1<br />

1<br />

,<br />

0<br />

0<br />

1<br />

0<br />

1<br />

4<br />

•<br />

•<br />

•<br />

•<br />

1<br />

•••••• 1 • ,,s1• • • • • of. ...P O W<br />

1<br />

,<br />

1<br />

-<br />

•<br />

•<br />

•<br />

•<br />

•<br />

•<br />

•<br />

•<br />

rft-Sin<br />

-<br />

I<br />

E<br />

l<br />

i<br />

An ARa e rs tra cing<br />

console window in<br />

action.<br />

Bug 1<br />

huntin<br />

ALL T r a c e s all clauses as they are executed.<br />

BACKGROUND This mode is the same as OFF except for the fact that the TS<br />

support program con not override it.<br />

COMMANDS A l l command clauses ore traced before being sent to the external<br />

host. Any non- zero return codes are also displayed.<br />

ERRORS C o m m a n d s which result in a non-zero error code are traced.<br />

INTERMEDIATES Clauses and all intermediate results of expression evaluation are<br />

traced (including values of variables, the results of function calls<br />

and expansion of compound names.<br />

LABELS<br />

NORMAL<br />

OFF<br />

RESULTS<br />

SCAN<br />

Traces labels reached either in sequence or via flow control<br />

statements.<br />

Default tracing mode. Similar to the ERRORS mode except that on<br />

error ceiling value (set using the OPTIONS FAILAT instruction<br />

Form) is used to determine whether or not an error trace should<br />

be generated.<br />

Tracing is turned off by this option although this situation can be<br />

overridden by ARexx's TS program.<br />

Traces the results of every expression that is evaluated.<br />

Similar to ALL but it is a parse-only scan so the program does not<br />

ac•ually get exerL tod.<br />

-11110111W I M P<br />

Tablet Sr Options a va ila ble . with AR e sx's TR AC E instruction<br />

THE TRACE INSTRUCTION<br />

The syntax of this instruction takes the<br />

general form—<br />

TRACE [ symbol I stringS I I [VALUE] expression]]<br />

which means that three basic forms of<br />

the instruction exist, namely:<br />

TRACE symbol<br />

TRACE string$<br />

TRACE [VALUE] expression<br />

where the symbol, string or expression<br />

must either represent (or reduce to) a<br />

positive or negative integer, or be one of<br />

the options (or a single letter abbreviation)<br />

shown in table 1. Negative numeric<br />

values, incidentally, indicate a 'suppression<br />

count', which turns ARexx's tracing<br />

off for a given number of clauses. A positive<br />

value given during interactive tracing<br />

indicates that a number of interactive<br />

'pauses for input' are to be skipped<br />

over.<br />

The trace output itself can be sent to<br />

one of three places: Directly back to stdout<br />

(which for programs launched from<br />

111111=Mit ' 1 1 1<br />

AMIGA COMPUTING<br />

FEBRUARY 1996<br />

•.J CU/Shell console is the CLI/Shell window<br />

itself); to a file associated with a<br />

standard error (stderr) file handle (this<br />

can of course be another console window);<br />

or to ARexx's Global Tracing<br />

Console (a special console which can be<br />

opened using the TCO utility program).<br />

Before deciding where trace information<br />

should be sent, AResix checks for<br />

the existence of an stderr file handle, if<br />

you have opened a window or file tied<br />

to this file handle, or have opened the<br />

Global Tracing Console (which is automatically<br />

attached to stderr), then ARexx<br />

will send its information to this destination,<br />

otherwise it will send its output<br />

through the standard output channel<br />

(stdoutl. The benefit of having trace<br />

information sent through a separate<br />

channel is simple - it avoids having<br />

trace output and normal program output<br />

intermixed at the same window.<br />

Of course, what we need now is a few<br />

examples of these facilities in action to<br />

drive home the ideas. Needless to say<br />

this is exactly what's coming in the next<br />

issuel

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!