Rockwell Automation 1771-DMC_DMC1_DMC4_DXPS Control Coprocessor User Manual User Manual
Page 58
![background image](/manuals/579606/58/background.png)
Chapter 4
Using the Programming Environment
4-6
The following example program—HELLO.BAS—is the BASIC version of
the C example program.
rem hello.bas
rem ********************************************************************
rem
rem This program is used as an example so you can learn the mechanics
rem of writing a Basic program using the control coprocessor.
rem
rem ********************************************************************
rem Declare some variables to be used later in the program.
DIM total, x, y: INTEGER
rem Send the ASCII control code “[2J” to clear the screen.
PRINT CHR$(27); “[2J”
rem Print a text string to the screen.
PRINT “Hello, world!”
rem Now try some math with the variables declared at the beginning.
x = 2
y = 5
total = x + y
PRINT “The results of our math test (x + y) is ”; total
This section shows a C program called CAT.C. It reads files from the
RAM disk and displays them to the screen; it is a simplified version of the
UNIX utility—
cat
—which concatenates files to standard output.
Figure 4.8 shows the output from the program CAT.C. The text displayed
is the concatenation of two files—HOSTS and HOSTS.EQUIV.
Figure 4.8
Access RAM Disk and Read File to Screen
Use an Example Application
Program to Access the
RAM Disk