Check for the existence of a file

The command #FILE EXIST checks whether a file exists in the file system and can open it. After calling #FILE EXIST the call result is saved to V.G. variables. This is retained until the next time #FILE EXIST is called.

 

V.G.<var_name>

 

Meaning

 

Data type

 

Unit of
In/Output

Permitted access
Read /
Write

FILE_EXIST

Result of data search. When the file is found, then 1

Boolean

0 , 1

L

FILE_EXIST_PATH_NAME *

Path with file name*

String

-

L

FILE_EXIST_DIRECTORY *

Path without file name. The path ends with '\' *

String

-

L

* Paths that are entered in the table of search paths in the start-up list (P-STUP-00018) or channel list (P-CHAN-00401) .

#FILE EXIST [ PATH="<filename>" ]

PATH<filename>

Name of the file whose existence is to be checked with or without directory specification.

The equals sign (=) is optional.

Attention

attention

RELATIVE DIRECTORIES:

If the PATH parameter is specified as relative, a search is made for the file in the folders of the start-up/channel parameter list.

The search is for the sequence main program - subroutine - work directory.

Programing Example

prg_example

Check for the existence of a file

%FileExist

N010 #FILE EXIST[PATH = "C:\TestDir\test.nc"]

N030 $IF V.G.FILE_EXIST == TRUE

N040 #MSG ["FILE EXISTS"]

N050 $ELSE

N060 #MSG ["FILE DOES NOT EXIST"]

N070 $ENDIF

N090 M30