Need code assistance (export from yesterday)

Brian K. White brian at aljex.com
Tue Jan 18 11:43:14 PST 2005


----- Original Message ----- 
From: "Matthew Williams" <matthew.d.williams at gmail.com>
To: "FilePro Mailing List" <filepro-list at lists.celestial.com>
Sent: Tuesday, January 18, 2005 11:22 AM
Subject: Need code assistance (export from yesterday)


> This is a follow up to the thread I started yesterday on exporting a
> bunch of text files based upon a field value in the record.  Working
> off of Brian Whites example code this is where i'm at below:
>
> At this point the process runs however I got no file output of
> anykind.  Without the end on line 4 I get stuck at the output process
> screen and am forced to kill the process manually.
>
> Thanks a lot!
> -Matt
> Hale Mfg.
>
> 1  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>       If: rc{"" ne 1{"" and rc ne ""
>       Then: close rep
> 
>   -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>       If: rc{"" ne 1{"" and rc ne ""
>       Then: rc(3,*,g)=1 ; of = "upss/invoices"{1{".txt"; gosub exp '
> This does the export and writes the header
> 
>   -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>       If:
>       Then: rep(1)=1;rep(2)=2;rep(3)=3;rep(4)=4;rep(5)=5;rep(6)=6;rep(7)=7
> ......
> 
>   -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>       If:
>       Then: end
> 
>   -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
> exp  If:
>       Then: export word rep = (of) -r=\n -f=,
> 
>   -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>       If: ' Export file header
>       Then: 
> rep(1)="SalesPerson";rep(2)="OrderNumber";rep(3)="AccountNumber"
> 
>   -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>       If:
>       Then: write;return 'Return back to write records to the file


Line 2 is not supposed to have anything on it's "IF:" part.
Yes you do need the end in this case because the example I posted didn't 
have the export in a gosub.
Now the there is any code below the field assignments, then there must be 
and end to form the end of the table.
You didn't have any header code in your original question so that makes the 
answer all different.
Gosub exp should oly have an export command and nothing else.
The header field assignments should be in a gosub header which itself calls 
gosub exp once, AND gosub exp should appear once at the top of the table for 
the normal data records. Call gosub header only on the first record and 
before doing the normal export.

Here's what it needs to look like now:
This time I'll try to explain as it goes along what each part does and why 
it's done just that way...

> 1  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>       If: rc{"" ne 1{"" and rc ne ""
>       Then: close rep

1: if rep changed then it's time to close the export file that is open from 
the previous record and start a new file. But watch out for rc = "" because 
on the very first record rc will not = 1 either, but there is no previous 
export file to close so don't try to close it.

> 
>   -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>       If: rc{"" ne 1{""
>       Then: rc(3,*,g)=1 ; of (255,*,g) = "upss/invoices"{1{".txt" ; gosub 
> header

2: if rep changed, including on very first record, remember new rep code, 
make a new file name and remember it, write a header

> 
>   -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>       If:
>       Then: gosub exp
> 
>   -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>       If:
>       Then: rep(1)=1;rep(2)=2;rep(3)=3;rep(4)=4;rep(5)=5;rep(6)=6;rep(7)=7
> ......
> 
> 9 -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>       If:
>       Then: end

3 - 19: write a data line, happens every record hense no "if:"

> 
>   -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
> exp  If: '*************************************
>       Then: export word rep = (of)
> 
>   -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>       If:
>       Then: return

20-21: export command that is used by both data and the header.
if csv is the desired output then "word" does it all, no need for args (In 
This Case)

> 
>   -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
> header If: '************************************
>       Then: gosub exp
> 
>   -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>       If: ' Export file header
>       Then: 
> rep(1)="SalesPerson";rep(2)="OrderNumber";rep(3)="AccountNumber"
> 
>   -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
>       If:
>       Then: return

22 - 24 : write a header line. It's basically a copy of the normal data 
export section, (3-19, export, followed by assignments) with hardcoded 
values and all put into a gosub so you can run it only as required via some 
test like @once or in this case whenever the rep code changes (rc ne 1)

Hope this clears things up a little.

Brian K. White  --  brian at aljex.com  --  http://www.aljex.com/bkw/
+++++[>+++[>+++++>+++++++<<-]<-]>>+.>.+++++.+++++++.-.[>+<---]>++.
filePro BBx  Linux SCO  Prosper/FACTS AutoCAD  #callahans Satriani



More information about the Filepro-list mailing list