ProSoft Technology MVI56-BAS User Manual

Page 47

Advertising
background image

MVI56-BAS ♦ ControlLogix Platform

Using the Program Port (PRT1)

BASIC Module (DB/BAS Compatible)

User Manual

ProSoft Technology, Inc.

Page 47 of 234

December 13, 2011

5.2

Creating BASIC programs

Creating a BASIC program is simple. First, hit the enter key a couple of times.

You should see the following response each time you hit the enter key:

Ready
>

If you do not get the above response, it is possible that the module is already

running a BASIC program. To stop a program that is already running, hit the 'C'

while simultaneously holding the control key down. The short symbol for this key

stroke combination is ^C. If you still do not get a response, check the module

power, check the serial cable, and check port connections.
After you get the Ready prompt, type in the BASIC command:

print "Hello World!"

followed by and enter key. The BAS module should respond with the following:

Ready
>print "Hello World!"
Hello World!
Ready
>

You just typed in a PRINT command. Practically any BASIC statement can also

be used as a command. For example:

Ready
>for i=0 to 5:p. i:next i
0
1
2
3
4
5
Ready
>

Note that the "p." is short hand for "PRINT".
The above approach can be used for debugging a program, but there are a few

problems writing a program this way. First, there is no permanent copy of the

program saved in memory. That is, the program disappears as soon as it is

executed. Second, you cannot write a program any longer than one line in length.

Third, someone has to be there to write the program each time it is executed.
You can write a program which is permanently saved and executes whenever

you want by adding line numbers at the beginning of each line. The program is

executed in the order matching the line number. For example:

Ready
>10 for i = 0 to 5
Ready
>20 p. i
Ready
>30 next i
Ready
>40 end
Ready
>list

Advertising