You Can View User Feedback To This Tip
In April of 2003, Vernon Hamberg submitted the tip, "Check object existence using IFS API". Vern's tip explains the steps to check object existence in the IFS using an API. There is a simpler method to discover if your file, folder or other IFS object exists in the IFS, without getting into custom commands and system API's.
A more practical method to discover if your file, folder or other
IFS object exists is to use the RENAME command. This is the same old DOS or UNIX command we used in the 1980's where you can rename the object to the same name it already has.
Typically, once you have navigated down the folder path of the IFS
to the actual folder using the WRKLNK command -- like WRKLNK OBJ(
'/folderA/folderB' ) or in batch work -- you would be using the CHGCURDIR or
the shortcut commands CHDIR or CD, and then you can rename your object to
the same name.
If however, you do not "walk" down the folder path when using the
Rename command, the first parm may
To continue reading for free, register below or login
To read more you must become a member of Search400.com
');
// -->

contain the full path name. If it does,
then you CANNOT use the full path name in the second parm. You will have to
extract the object's name so it does not contain any slashes of the folder
path.
REN OBJ('folderA/folderB/fileC') NEWOBJ('fileC')
You then get the completion message CPCA084 = Object Renamed
If it does not exist, you receive the diagnostic message of severity 40
CPFA0A9 = Object not found.
This same technique could be applied to the COPY command, however, the
RENAME works for both files and folders, which is why I prefer using it.
USER FEEDBACK TO THIS TIP
==================================
MORE INFORMATION ON THIS TOPIC
==================================
The Best Web Links: tips, tutorials and more.
Ask your programming questions--or help out your peers by answering them--in our live discussion forums.
Ask the Experts yourself: Our application development gurus are waiting to answer your programming questions.