Parker Hannifin
Open Sample
PROGRAM
CLEAR : REM Clear any variables dimension in program
DIM $V(1,10) : REM Dimensions one string variable of length 10
GOSUB OPENPORT : REM Go to SUBROUTINE OPENPORT
END
'SUBROUTINE OPENPORT
_OPENPORT
'Opens Ethernet Stream2
OPEN "STREAM3:" AS #1
'Continuous loop as long as "X" is not entered
_LOOP1
'Set String Variable 0 to nothing
$V0 = ""
PRINT #1, ""
PRINT #1, "What kind of fruit do you want?"
PRINT #1, "(A)pple, (B)anana, (C)oconut"
PRINT "I would like to have a";
'Infinite WHILE loop if they do not enter anything
WHILE ($V0 = "")
$V0 = UCASE$(INKEY$(1))
REM Stores Keyboard entry into String Variable 0
WEND
IF ($V0 = "A") THEN PRINT "n Apple"
REM If "A" was entered, then print n Apple
IF ($V0 = "B") THEN PRINT " Banana"
REM If "B" was entered, then print Banana
IF ($V0 = "C") THEN PRINT " Coconut"
REM If "C" was entered, then print Coconut
IF ($V0 = "X") THEN GOTO LOOP2
REM If "X" was entered, then goto LOOP2 to terminate program
IF ($V0 = CHR$(27)) THEN GOTO LOOP2
REM If "ESC key" was entered, then goto LOOP2 to terminate program
'Goes back to LOOP1
GOTO LOOP1
_LOOP2
PRINT #1, "Program terminated"
CLOSE #1
RETURN
ENDP
96 Programmer’s Guide