2-803
2 Instruction Descriptions
NJ-series Instructions Reference Manual (W502)
SD Memory Card Instructions
2
FileOpen
FileOpen
The FileOpen instruction opens the specified file in the SD Memory Card.
* _READ_EXIST, _RDWR_EXIST, _WRITE_CREATE, _RDWR_CREATE, _WRITE_APPEND and _RDWR_APPEND
The FileOpen instruction opens the file specified by FileName in the SD Memory Card in the mode
specified by Mode. The result is output to file ID FileID. FileID is used to specify the file in other instruc-
tions, such as FileRead and FileWrite.
The data type of Mode is enumerated type _eFOPEN_MODE. The meanings of the enumerators are as
follows:
Instruction Name FB/FUN Graphic expression ST expression
FileOpen Open File FB FileOpen_instance(Exe-
cute, FileName, Mode,
Done, Busy, Error, ErrorID,
FileID);
Variables
Name Meaning I/O Description Valid range Unit Default
FileName File name
Input
Name of file to open
Depends on data type.
---
''
Mode Open mode Mode in which to open file * _READ_
EXIST
FileID File ID Output ID of file that was opened Depends on data type.
--- ---
Boolean
Bit strings Integers
Real
numbers
Times, durations,
dates, and text strings
BOOL
BYTE
WORD
DWORD
LWORD
USINT
UINT
UDINT
ULINT
SINT
INT
DINT
LINT
REAL
LREAL
TIME
DATE
TOD
DT
STRING
FileName OK
Mode Refer to Function for the enumerators for the enumerated type _eFOPEN_MODE.
FileID OK
Function
Enumerator Meaning
_READ_EXIST Use this value to open a text file to read it. The file is read from the beginning.
_RDWR_EXIST Use this value to open a file to read and write it. The file is read and written from the
beginning.
_WRITE_CREATE Use this value to open a file to write it. If the file already exists, the contents is dis-
carded and the file size is set to 0. If the file does not exist, a new file is created. The
file is written from the beginning. However, if the file already exists and it is write-pro-
tected, an error occurs and the file is not opened.
FileOpen
Execute Done
FileName Busy
Mode Error
ErrorID
FileID
FileOpen_instance