How do I force export from within a loop

Mike Schwartz (PC Support) mschw at athenet.net
Wed Aug 17 15:11:53 PDT 2005


> -----Original Message-----
> From: filepro-list-bounces at lists.celestial.com [mailto:filepro-list-
> bounces at lists.celestial.com] On Behalf Of John Esak
> Sent: Wednesday, August 17, 2005 12:10 PM
> To: filePro mailing list
> Subject: RE: How do I force export from within a loop
> 
> > I have a routine that prints the letters using FilePro and the "FORM"
> > command to force output but have not found a command to force "export "
> > within a getnext loop.
> > ----------------------------------
> >
> >      I know John Esak already explained that you can do this by passing
> > through the export line once for each record you want written, but here
> is
> > another method:
> >
> >      Once you open the export file, you can use the "write"
> > command to write
> > a single line to it.  For example, if you open an export file
> > with an alias
> > like "lout = lettersout.csv", inside your loop, put the statement "write
> > lout" inside your loop at any point where you want to write a new line
> to
> > the lettersout.csv file.
> >
> >      I can send you a sample bit of code that shows how to do this, if
> you
> > still can't figure it out.  Otherwise, Stuart Werner has a full
> > example and
> > explanation on page 381 of the 4th edition of his filePro training
> manual.
> > (I think he has explained this in all previous versions of his book, as
> > well...)
> >
> > Mike Schwartz
> 
> Mike,
> 
> This is not correct. If Stuart has explained it that way in his book, no
> matter how many times he's reprinted it, he's still wrong. A WRITE will in
> no way export a line to an export file. Unless, the EXPORT line itself is
> within the loop (getnext or any other kind of loop which gets successive
> records) nothing will be added to the export file. So, unless you mean
> something else, or Stuart explained it some other way, this is just not
> correct.
> 
> You could put the EXPORT *and* a WRITE inside a loop and export successive
> records, but it still won't be the WRITE that does the exporting... It
> will
> only ensure an immediate in-line write, that's all.
> 
> However, I do put WRITE's inside of every getnext loop which is changing
> data in the lookup file. It has solved a myriad of problems, and it hurts
> nothing.
> 
> John Esak

     Hmmm... Maybe I'm not remembering this correctly, but I could swear
that I have put writes inside loops (where there is only one export at the
top of the table and not in the loop) and they work.  I've done this for
years to write out multiple lines from inside master inventory records and
such; one for each location where the inventory is stored.

     My apologies to Stuart if I misquoted him, but I could have sworn that
I picked up this technique from one of the examples in his book.  When I get
back to my office, I will connect into one of my customer computers where I
recall having done this and look at my code again and report back to you.

     I think the key might be that I may be adding a CR/NL to the end of
each line, and filePro is really putting out one long line, but it appears
to work because I see multiple lines when I look at the output file that I
have created myself!

Sorry for any confusion...

Mike Schwartz
      



More information about the Filepro-list mailing list