Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

4gl writing to a pure text file

145 views
Skip to first unread message

Keith Root

unread,
Jun 27, 1994, 2:56:24 PM6/27/94
to
I have the need to create a flat ascii file for an off line application.
The file is fixed length, 192 characters.
What is the easiest/fastest way from a 4gl program to write to an ascii text
file? I have come up with some of the following.

1. use the run command to echo >> filea - after formatting rows
2. create table with 1 column (192 char) and format a variable in the 4gl
code and update/insert - unload and strip "|" (2 passes - seems messy)

can someone point me to doco (4GL - 4.01) or have any ideas??

---------------------------------------------------------------------
| Keith E. Root internet: kei...@winternet.com |
| National Business phone : 1-612-647-0143 |
| Data Systems, Inc. fax : 1-612-642-0913 |
| Microwaves will frizz your heirs! |
---------------------------------------------------------------------

Paul Roberts

unread,
Jun 27, 1994, 6:48:07 PM6/27/94
to
In article <2un7co$n...@blackice.winternet.com> kei...@winternet.com (Keith Root) writes:
>I have the need to create a flat ascii file for an off line application.
>The file is fixed length, 192 characters.
>What is the easiest/fastest way from a 4gl program to write to an ascii text
>file? I have come up with some of the following.
>
>1. use the run command to echo >> filea - after formatting rows
>2. create table with 1 column (192 char) and format a variable in the 4gl
> code and update/insert - unload and strip "|" (2 passes - seems messy)
>
>can someone point me to doco (4GL - 4.01) or have any ideas??

Well, you could always just write out a report with

top margin 0
bottom margin 0
left margin 0
right margin 0
page length 1

- the output is pretty flat, pretty ascii. I don't know any reason why
this wouldn't get you what you want.

Paul

Milt Webb

unread,
Jun 27, 1994, 10:07:46 PM6/27/94
to
Keith Root (kei...@winternet.com) wrote:
: I have the need to create a flat ascii file for an off line application.

: The file is fixed length, 192 characters.
: What is the easiest/fastest way from a 4gl program to write to an ascii text
: file? I have come up with some of the following.

: 1. use the run command to echo >> filea - after formatting rows
: 2. create table with 1 column (192 char) and format a variable in the 4gl
: code and update/insert - unload and strip "|" (2 passes - seems messy)

: can someone point me to doco (4GL - 4.01) or have any ideas??

Keith,
Do it with a report. Just set the lines per page to 1 and the margins
appropriately. We use this in our conversion programs all the time.
One thing you have to be aware of is when the report is "finished" you
will get one blank line at the end. You can suppress this by getting
a count of rows within the report and using a print statement with a
semicolon for the last row. If you need some sample code e-mail me
at m...@servantis.com ...

Milt Webb
--
------------------------------------------------------------------------------
Milt Webb | email addresses> milt...@netcom.com
Servantis Systems, Inc. | m...@servantis.com
4411 East Jones Bridge Road | m...@atl.fujikura.com
Norcross, GA 30092 | Phone 404/840-1365(W) or 404/945-5896(H)

Ron Delpiere-Smith

unread,
Jun 27, 1994, 10:09:33 PM6/27/94
to
kei...@winternet.com (Keith Root) writes:

>I have the need to create a flat ascii file for an off line application.
>The file is fixed length, 192 characters.
>What is the easiest/fastest way from a 4gl program to write to an ascii text
>file? I have come up with some of the following.

>1. use the run command to echo >> filea - after formatting rows
>2. create table with 1 column (192 char) and format a variable in the 4gl
> code and update/insert - unload and strip "|" (2 passes - seems messy)

>can someone point me to doco (4GL - 4.01) or have any ideas??

There are a nuber of ways to write out to a flat text file. Which one is the
best depends of the application. My favorite way is to call a 'c' function
that performs file_io. I have some source that I can E-mail to you or any
one needing it. This code is of my own and not of Informix. It was developed
about 7 or 8 years ago and has been used on several platforms without any
problems.

Ron Delpiere-Smith
re...@informix.com

James Holthaus

unread,
Jun 28, 1994, 9:22:36 AM6/28/94
to
In Article <2un7co$n...@blackice.winternet.com>, kei...@winternet.com (Keith

Root) wrote:
>I have the need to create a flat ascii file for an off line application.
>The file is fixed length, 192 characters.
>What is the easiest/fastest way from a 4gl program to write to an ascii text
>file? I have come up with some of the following.
>
>1. use the run command to echo >> filea - after formatting rows
>2. create table with 1 column (192 char) and format a variable in the 4gl
> code and update/insert - unload and strip "|" (2 passes - seems messy)
>
>can someone point me to doco (4GL - 4.01) or have any ideas??

How about a report to a file name? That seems much easier and less
cumbersome.
--
James Holthaus email: james-h...@uiowa.edu
Programmer Analyst Iowa Memorial Union Business Office University of Iowa

Li Chuan Dunlop

unread,
Jun 28, 1994, 9:50:31 AM6/28/94
to
kei...@winternet.com (Keith Root) writes:


Option 1 is possibly the easiest, however it you're dealing with a lot
of output it can be significantly slow:

We had a similar requirement, to produce a flat file of about 100,000
lines. A simple experiment:

Create a C program file (eg. /tmp/test.c):
main() {
int i;
for (i=0; ++i<500;)
system("echo hello world >> /tmp/test.out");
}

cc -o /tmp/test /tmp/test.c
time /tmp/test

real 0m20.54s
user 0m0.47s
sys 0m1.85s

This essentially duplicates the process the 4GL code will be doing.

This test shows that for 100,000 records, just running the echo will
take more than an hour (this is on my home computer - 486/66 SVR4.2).
Actually, on the production system this test showed that running the echo
would have taken somewhat over 8 hours (ok, ok - so it's a dog-box and it
has other work to do...).

The reason it's so inefficient is that the 'RUN' command has to start
up a new shell every time it's called, and starting new processes is
quite 'expensive' in term of machine resources/time. You would usually
not notice this (it you're not on a dog-box like ours), but if you try
doing it a lot of times it all adds up...

All this said, if the process is not expected to be run on a lot of rows and
isn't run frequently, or the elapsed time doesn't matter, your option 1 is a
reasonable way to go.

Just don't tell our programmer, who got blasted for putting the 'RUN echo'
command in a production program. And this in a program they knew was
'runtime-critical'. Some people have no idea.

---------------------------
LiChuan Dunlop
s92...@minyos.rmit.edu.aus
---------------------------

0 new messages