Sample Code for File Exists

The sample code below should be entered inside the Edit window's Command mode and 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.

Command Mode Commands after Comments

After you insert a PC-DMIS comment, to type additional PC-DMIS commands in Command Mode, you must first press Enter twice after the COMMENT command. This tells PC-DMIS that you no longer want to add text to the comment but are ready to add a new command.