Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

check file existance in progress 4GL

How to check existance of particular file by use of code. Eg. def var a as character. a = "abc.p"

run value(a). ---> here first i want to check if abc.p exist in workspace or not.

like image 417
Nilesh Pharate Avatar asked Dec 11 '22 09:12

Nilesh Pharate


1 Answers

You can use the SEARCH function. Directly from the online manual:

SEARCH function Searches the directories and libraries defined in the PROPATH environment variable for a file. The SEARCH function returns the full pathname of the file unless it is found in your current working directory. If SEARCH does not find the file, it returns the Unknown value (?).

Syntax

SEARCH ( opsys-file ) 

opsys-file

A character expression whose value is the name of the file you want to find. The name can include a complete or partial directory path. If opsys-file is a constant string, you must enclose it in quotation marks (" "). The value of opsys-file must be no more than 255 characters long.

Example:

DEFINE VARIABLE cPgm AS CHARACTER   NO-UNDO.

cPgm = "test.p".

IF SEARCH(cPgm) <> ? THEN 
    RUN VALUE(cPgm).
  • If you provide a fully qualified pathname, SEARCH checks if the file exists. In this case, SEARCH does not search directories on the PROPATH.
like image 195
Jensd Avatar answered Jan 31 '23 12:01

Jensd