Debugging example -11, Debugging example – Rockwell Automation 1747-PBASE BASIC Development Software Programming Manual User Manual

Page 111

Advertising
background image

Publication 1746-PM001A-US-P

Communicating with the Module 9-11

Debugging Example

The following example program will be used to illustrate the debugging features. It
is a simple program so that you can visualize each line’s execution as it is being
debugged.

REM THIS IS A DEBUGGING EXAMPLE

{SORT EVEN NUMBERED POSITIVE ENTRIES}

{$L START}

INPUT ”ENTER A NUMBER: ”,Y

FOR X=1 TO Y

IF X*2=Y THEN GOTO DONE

NEXT X

PRINT ”NUMBER IS ODD OR LESS THAN 1, RESTARTING”

GOTO START

{$L DONE}

PRINT ”NUMBER IS EVEN”

END

After entering the program, save it under the name DEBUG.BDL, and then
translate/compile it. If there are no errors, go to Terminal mode and download the
translated file (DEBUG.BAS) to the module. Follow the steps below to observe the
features available with the BASIC Debugger:

1. After downloading, type

RUN

to execute the program. You are prompted to

enter a number. If not, you may have a bug in the program, using the debugger
may help you find it.

2. Enter an odd number (less than 100) and press

[Enter]

. A message appears

indicating it is odd. You are prompted to enter a number again.

3. Enter an even number (less than 100) and press

[Enter]

. A message appears

indicating it is even, and the program terminates.

4. Select

deBug

from the menu at the top of the screen, then select

Run

Debugger

. If you have loaded a previously translated file for which a .MAP file

exists (as is the case with this example), a message appears indicating that
.MAP file will be used.

5. Press any key to continue. A split screen appears with your program

(DEBUG.BDL) above and a watch window below. The watch window is
where the variable values you designate will be displayed.

Advertising