3 Description of functions
3-6
M_OPEN
[Function]
Indicates whether or not the file has been opened.
[Format]
<Numeric variable> = M_OPEN [(<file number>)]
[Terminology]
<Numeric variable> Specify a numeric variable to be assigned.
<File number> Specify a file number constant between 1 and 8 for the communication line that
was opened by the OPEN instruction. If omitted, 1 is set. If 9 or higher is
specified, an error occurs when executed.
[Reference Program]
1 ' Client Program ----------------
2 M1=0
3 M_TIMER(1)=0 ‘Resets the timer to 0.
4 *LOPEN:OPEN "COM2:" AS #1 ‘Opens the line.
5 IF M_TIMER(1)>10000.0 THEN *LERROR ‘Jumps when 10 seconds elapses.
6 IF M_OPEN(1)<>1 THEN GOTO *LOPEN ‘Loops if no connection is made.
7 DEF ACT 1,M_OPEN(1)=0 GOSUB *LHLT2 ‘Monitors the down state of the server using an interrupt.
8 ACT 1=1 ‘Starts monitoring.
9 *LOOP:M1=M1+1
10 IF M1<10 THEN C1$="MELFA" ELSE C1$="END" ‘Sends END after sending the “MELFA” string nine times.
11 PRINT #1,C1$ ‘Sends a character string.
12 INPUT #1,C2$ ‘Receives a character string.
13 IF C1$="END" THEN *LHLT ‘Jumps to CLOSE after sending “END.”
14 GOTO *LOOP ‘Loops.
15 *LHLT:CLOSE #1 ‘Closes the line.
16 HLT ‘Halts the program.
17 END ‘Ends.
18 *LERROR:ERROR 9100 ‘Generates error 9100 if no connection can be made to the
server.
19 CLOSE #1
20 HLT
21 END
22 ERROR 9101 ‘Generates error 9101 if the server is down during
processing.
23 *LHLT2:CLOSE #1
24 HLT
25 END