Function BlockFileOpenWPLCopen motion icon

Description

This function block opens a file for writing. If a file already exists, it will be overwritten.

Files must be closed using the FileClose function block.


  • The controller allows only 32 open files at any given time.

Figure 7-199: The FileOpenW function block

Related Functions

FileClose, FileEOF, FileOpenA, FileOpenR, FileReadLine, FileReadBinData, FileSeek, FileWriteBinData, FileWriteLine

Arguments

Input

Execute Description On the rising edgeClosedA rising edge is the transition of a digital signal from low to high. It is also called positive edge request to open a file
  Data Type BOOL
  Range 0, 1
  Unit n/a
  Default
Path Description The path of the file to open or create.
  Data Type STRING
  Range n/a
  Unit n/a
  Default

Output

Done Description If TRUE, then the command completed successfully
  Data Type BOOL
Error Description If TRUE, an error has occurred
  Data Type BOOL
ErrorID Description Indicates the error if Error output is set to TRUE. See the table in Search IndexFile and TCP/IP Function Block ErrorID Output
  Data Type DINT
ID Description ID of the open file.
  Data Type UDINT

Example

Structured Text

(* FileOpenW example *)
(* Replace FileOpenW with FileOpenA or FileOpenR as needed*)
CASE StepCounter OF
0:
  Inst_FileOpenW(TRUE, 'Results.txt');
  StepCounter := StepCounter + 1;
1:
  Inst_FileOpenW(TRUE, 'Results.txt');
  IF Inst_FileOpenW.Done THEN
     ResultsFileID := Inst_FileOpenW.ID;
     Inst_FileOpenW(FALSE, '');
     StepCounter := StepCounter + 1;
  END_IF;
END_CASE;