#### Sample Code for File Exists

The sample code below should be entered inside the Edit window's Command Mode, not inside the File I/O dialog box.

The following code asks for a file name and then checks for the file's existence.

C1=COMMENT/INPUT,Please type a file you want to check.

V1=FILE/EXISTS,C1.INPUT

IF/V1<>0

COMMENT/OPER,File exists.

END_IF/

ELSE/

COMMENT/OPER,File doesn't exist

END_ELSE/

Code Explanation

Much of this code is similar to that explained in "Sample Code for Read Character" or in "Sample Code for Read Line".

Only explanations unique to this example are given here.

V1=FILE/EXISTS,C1.INPUT
This line checks to see if the specified file exists. The file must be placed in the directory where PC-DMIS resides for this code to work, otherwise the line containing the file must also contain the full pathway for the file. V1 receives the result of the file check. It's a non-zero value if it exists; 0 otherwise.