Function BlockFileExistsPLCopen motion icon

Description

This function block tests if a file exists.

Figure 7-205: The FileExists Function Block

Related Functions

FileCopy, FileDelete, FileRename, FileSize

See also: File Management

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 test to see if a file exists
  Data Type BOOL
  Range 0, 1
  Unit N/A
  Default
Path Description The path to the file
  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
Exists Description

The existence of the file.

True: this value indicates the file exists

False: this value indicates the file does not exist.

  Data Type BOOL

Example

Structured Text

(* FileExists example *)
CASE StepCounter OF
0:
  Inst_FileExists(TRUE, 'Test.txt');
  StepCounter := StepCounter + 1;
1:
  Inst_FileExists(TRUE, 'Test.txt');
  IF Inst_FileExists.Done THEN
     TestFileExists := Inst_FileExists.Exists;
     Inst_FileExists(FALSE, '');
     StepCounter := StepCounter + 1;
  END_IF;
END_CASE;