2 Instruction Descriptions
2-804
NJ-series Instructions Reference Manual (W502)
The following figure shows a programming example. The file named ‘Temp/f_name’ is opened to
append data to it. The file ID is assigned to variable mno.
_RDWR_CREATE Use this value to open a file to read and write it. If the file already exists, the contents
is discarded and the file size is set to 0. If the file does not exist, a new file is created.
The file is read and written from the beginning.
_WRITE_APPEND Use this value to open a file to append data to it. If the file does not exist, a new file is
created. The data is appended to the end of the file. However, if the file already exists
and it is write-protected, an error occurs and the file is not opened.
_RDWR_APPEND Use this value to open a file to read and append data to it. If the file does not exist, a
new file is created. The file is read from the beginning. The data is appended to the
end of the file.
Related System-defined Variables
Name Meaning Data type Description
_Card1Ready SD Memory Card
Ready Flag
BOOL This flag indicates if the SD Memory Card is physi-
cally inserted and is mounted normally, i.e., if it can
be accessed by instructions and communications
commands.
TRUE: Can be used.
FALSE: Cannot be used.
_Card1Protect SD Memory Card Write
Protected Flag
BOOL This flag indicates if the SD Memory Card is write
protected when it is inserted and ready to use.
TRUE: Write protected.
FALSE: Not write protected.
_Card1Err SD Memory Card Error
Flag
BOOL This flag indicates if an unspecified SD Memory
Card (e.g., an SDHC card) is mounted or if the for-
mat is incorrect (i.e., not FAT16 or corrupted).
TRUE: Error.
FALSE: No error.
_Card1Access SD Memory Card
Access Flag
BOOL This flag indicates if the SD Memory Card is cur-
rently being accessed.
TRUE: Being accessed.
FALSE: Not being accessed.
_Card1PowerFail SD Memory Card
Power Interruption Flag
BOOL This flag indicates if an error occurred in completing
processing when power was interrupted during SD
Memory Card access. This flag is not cleared auto-
matically.
TRUE: Error.
FALSE: No error.
Enumerator Meaning
FileOpen_instance(A, ‘Temp/f_name.bin’,
_WRITE_APPEND, abc,
def, ghi, jkl, mno);
LD
ST
A
’Temp/f_name.bin’
_WRITE_APPEND
FileOpen
Execute Done
FileName Busy
Mode Error
ErrorID
FileID
FileOpen_instance
def
ghi
jkl
mno
abc