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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

fixed format file input

Status
Not open for further replies.

moskhan

Programmer
Jul 7, 2007
6
US
hi
I am a newbie at progress and I am stuck at a simple problem. How can I read text from a fixed format file. The example I am provided with uses SET STREAM to read space delimited numbers. But since text has spaces in it. This code does not work.

Can anyone suggest something?
moskhan

PS: is it possible to provide the names of the input files into progress code as arguments? Just like C where the main function works with argc, argv?
 
I would suggest you load a variable with the entire contents of your input record and then use the SUBSTRING function to split out the individual field contents.

Progress also provides a 'quoter' utility which can convert files with fixed formats or delimited formats to the space-delimited, quoted format that is the standard Progress import format.

------

Re filenames as arguments, you could call a program like this:
Code:
RUN program-name.p(INPUT "c:\your\filename\here.txt").

The program would contain code like:
Code:
DEFINE INPUT VARIABLE v-filename.
INPUT FROM value(v-filename).

 
OOPS ALERT!!!

The program code should actually be:
Code:
DEFINE INPUT VARIABLE v-filename AS CHARACTER.
INPUT FROM value(v-filename).
 
Thanks Mad Michael,
Your suggestions showed me another way of tackling that problem. I later found examples of fixed format code which showed me my error.

Apparently, progress expects to see 1 space between variables (regardless of whether there are spaces within your string inputs). My input format had been
<8 char><40char><10char>.... As soon as I put spaces in between the fields (<8 char> <40char> <10char> ....) my program worked perfectly.

just thought you would want to know what I did.

moskhan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top