Function Description
The CREATE_FILE function enables creation of a file
called FILENAME, if it doesn’t exist, and allows it
to be opened with the specified ModeFlag flag:
O_RDONLY: opening in read-only mode (value 0),O_WRONLY: opening in write-only mode (value 1),O_RDWR: opening in read and write mode (value 2),
This flag is reset to 0 once the file is closed.
The file is created in the \DataStorage\. sub-directory
If you use the simulator mode the file is created in the temporary user folder.
To access the file by FTP refer to this page.
This will be used when you close the file. If you open a new file without closing the previous one, a new FileDescriptor parameter value is returned, and you will not be able to close the previous file.Therefore you should save the FileDescriptor parameter after opening a file.
When the maximum number of opened files is reached, an error is returned if you try to open any further files.
CREATE_FILE is similar to that of OPEN_FILE.The additional
parameters EN and ENO can be configured.
FBD Representation
The representation in FBD of the CREATE_FILE function is as follows:

Ladder Representation
The representation in Ladder of the CREATE_FILE function is as follows:

IL representation
Representation:
CAL CREATE_FILE_Instance (REQ:=CreateFileStart, SLOT:=CreateFileSlot, FILENAME:=CreateFileName, MODEFLAG:=CreateFileModeFlag, DONE=>CreateFileDone, ERROR=>CreateFileError, STATUS=>CreateFileStatus, FILEDESC=>CreateFileDescriptor)
ST representation
Representation:
CREATE_FILE_Instance (REQ:=CreateFileStart, SLOT:=CreateFileSlot, FILENAME:=CreateFileName, MODEFLAG:=CreateFileModeFlag, DONE=>CreateFileDone, ERROR=>CreateFileError, STATUS=>CreateFileStatus, FILEDESC=>CreateFileDescriptor);
Parameter Description
The following table describes the input parameters:
Parameter |
Type |
Comment |
|---|---|---|
|
|
This parameter specifies the slot address of the memory card (always has address 0). |
|
|
This parameter specifies the name of the file to create. Maximum number of characters : 64 Characters like ‘ ?’ or ‘ * ‘ are not allowed. |
|
|
This parameter specifies the opening mode.
|
The following table describes the output parameters:
Parameter |
Type |
Comment |
|---|---|---|
|
|
This parameter allows the DATA_STORAGE function to access the file. |
Description of common parameters.

