question about Progress : SEARCH COMMAND

chipke

New Member
Hello,

I want to check if a certain directory exist with the SEARCH function. I tried the following code:
DEFINE VARIABLE cPath AS CHARACTER NO-UNDO.
cPath = SEARCH("e:\test\").
MESSAGE cPath VIEW-AS ALERT-BOX.

RETURNS ?

DEFINE VARIABLE cPath AS CHARACTER NO-UNDO.
cPath = SEARCH("e:\test").
MESSAGE cPath VIEW-AS ALERT-BOX.

returns ?

I tried it with directorys inside my propath and outside. What is wrong?

Kind regards,
Tom
 

joey.jeremiah

ProgressTalk Moderator
Staff member
search( ) only works on files


try -

file-info:file-name = "e:\test".

if file-info:full-pathname <> ? then
message "Directory exists" view-as alert-box.

else
message "Directory does not exist" view-as alert-box.
 

lord_icon

Member
Greetings,
The SEARCH operation will NOT find directories that is why an unknown is returned.
The search operation will search the propath for files ONLY.
Choi
 

sridevi.stalin

New Member
Dear Chipke,
I've given one sample pgm for, if v know the file name, but want the directory of the filename, then the bellow sample may help....

DEFINE VARIABLE lcDir AS CHARACTER INITIAL "X(70)" NO-UNDO.
DEFINE VARIABLE lcFileName AS CHARACTER NO-UNDO.
ASSIGN lcFileName = "PrintImage.p".
IF SEARCH(lcFileName) <> ? THEN
DO :
lcDir = SEARCH(lcFileName).
MESSAGE ENTRY(1, lcDir, lcFileName) VIEW-AS ALERT-BOX INFO BUTTONS OK.
END.
in the above pgm,
the lcFileName is searched with in our application - propath.
if the specified file name is not in the propath, then shows nothing.
 

chipke

New Member
Dear Chipke,
I've given one sample pgm for, if v know the file name, but want the directory of the filename, then the bellow sample may help....

DEFINE VARIABLE lcDir AS CHARACTER INITIAL "X(70)" NO-UNDO.
DEFINE VARIABLE lcFileName AS CHARACTER NO-UNDO.
ASSIGN lcFileName = "PrintImage.p".
IF SEARCH(lcFileName) <> ? THEN
DO :
lcDir = SEARCH(lcFileName).
MESSAGE ENTRY(1, lcDir, lcFileName) VIEW-AS ALERT-BOX INFO BUTTONS OK.
END.
in the above pgm,
the lcFileName is searched with in our application - propath.
if the specified file name is not in the propath, then shows nothing.



Thanks But what will you do when you have a pathname and you only want to have the directory or the filename?

Kind regards,
Tom
 
Top