FileOpenW

PLCopen motion icon

 Function BlockClosed A function block groups an algorithm and a set of private data. It has inputs and outputs. - Create or resetClosed New start of the microprocessor. a file and open it for writing.

Inputs

Input

Data Type

Range

Unit

Default

Description

Execute

BOOL

0, 1

N/A

No default

On the rising edgeClosed The transition of a digital signal from low to high. AKA: positive edge., request to open a file.

PathClosed Set of continuous positions and orientation information in multi-dimensional space. Geometrical description of a space curve that the TCP of an axesgroup moves along.

STRING

N/A

N/A

No default

The path to the file.

Outputs

Output

Data Type

Range

Unit

Description

Done

BOOL

 

 

If TRUE, the command completed successfully.

Error

BOOL

 

 

If TRUE, an error has occurred.

ErrorID

DINT

 

 

Indicates the error if Error output is TRUE.

See the table in Search IndexFile and TCP/IP Function Block ErrorIDs.

ID

UDINT

 

 

The ID of the open file.

Remarks


  • The controller allows only 32 open files at any given time.
  • If a file already exists, it is overwritten.
  • Files must be closed using the FileClose function block.

Figure 1: FileOpenW

FBD Language Example

Not available.

FFLD Language Example

Not available.

IL Language Example

Not available.

ST Language Example

(* 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;

See Also