4MELFA-BASIC IV
Detailed explanation of command words
4-234
Open (Open)
[Function]
Open the file or communication lines.
[Format]
[Terminology]
<File Descriptor>
Describe a file name (including communication lines).
*To use a communication line, set "<Communication Line File Name>:"
*When not using a communications line, set "<File Name>"
<Mode>
Designate the method to access a file.
*Omitted = random mode. This can be omitted when using a communication line.
*ÅEInput = input mode. Inputs from an existing file.
*OUTPUT = output mode (new file). Creates a new file and outputs it there.
*APPEND = Output mode (existing file). Appends output to the end of an existing file.
<File No.>
Specify a constant from 1 to 8.
To interrupt from communication line: 1 to 3.
[Reference Program]
(1) Communication line.
1 Open "COM1:" AS #1
' Open standard RS-232C line as file No. 1.20 Mov P_01
2 Mov P_01
3 Print #1,P_Curr
' Output current position to external source.
"(100.00,200.00,300.00,400.00)(7.0)" format
40Input #1,M1,M2,M3
' Receive from external source with "101.00,202.00,303.00" AscII for-
mat.
5 P_01.X=M1
6 P_01.Y=M2
7 P_01.C=Rad(M3)
' Copy to global data.
8 Close
' Close all opened files.
9 End
(2) File operation. (Create the file "temp.txt" to the controller and write "abc")
1 Open "temp.txt" FOR APPEND AS #1
2 Print #1, "abc"
3 Close #1
[Explanation]
(1) Opens the file specified in <File name> using the file number.
Use this file No. when reading from or writing to the file.
(2) A communication line is handled as a file.
[Related instructions]
[Related parameter]
COMDEV
Open[] "<File Descriptor>" [][For <Mode>][]AS[] [#] <File No.>
File type
File name
Access method
File
Describe with 16 characters or less.
Input,OUTPUT,APPEND
Communi-
cation line
COM1: Standard RS-232C(default value)
COM2:The setting in the "COMDEV" parameter.
:
COM8:The setting in the "COMDEV" parameter.
Omitted = random mode only