Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

file reading question

Status
Not open for further replies.

moskhan

Programmer
Jul 7, 2007
6
US
Hi
One of our progress scripts was reading in a group of files
(../irepdata.20070701.txt, ../irepdata.20070801.txt, etc..)
using the INPUT STREAM command
INPUT STREAM s-in THROUGH VALUE ("cat ../irepdata.*.txt") NO-ECHO.

however problems happened when I introduced the following set of files. (../irepdata.catg.20070701.txt ../irepdata.catg.20070801.txt).

Temporarily I have changd the name of the files so that the * operator gives the right results but was wondering if there are better solutions anyone is aware of.

I thought of changing the script to use a DO loop(since I only need to read in files generated over a certain time period) and inside each loop, to create filenames in a tempstring and then use "INPUT STREAM s-in FROM VALUE(..)" but how do I check whether a file exists or not?

I looked up the progress manuals and thought that SEARCH would help, however it relies on an environment variable $PROPATH, and I do not want that.

can anyone suggest a solution?

thanks
moskhan
 
Check out the FILE-INFO session handle. It will do everything you want.

Create filenames as you suggested. Loop around your filenames doing something like the following:

Code:
ASSIGN FILE-INFO:FILE-NAME = myFileName.

IF FILE-INFO:FILE-TYPE MATCHES "*F*"
THEN DO:
    INPUT FROM ... etc
END.

Cheers, Mike.
 
Mike
thank you for the suggestion, however FILE-INFO will not work with relative paths if the PROPATH variable is not set, I cannot set that variable on the machines the script is running, how can I then provide paths of type "../data/irepdata.fil" ?

moskhan
 
sorry mike for the previous post, FILE-INFO works with relative paths also, I had some other mistake in my code.
 
Looks like you got your solution, then.

If you look at the online help for the FILE-INFO handle, you'll see it has lots of other attributes, including PATHNAME and FULL-PATHNAME.

Cheers, Mike.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top