Friday afternoon rant

Ian Wood iwood51 at gmail.com
Mon May 7 11:35:23 PDT 2012


Brian, I do simplify the exports to a few lines, even with 999 fields.

First I fill an array with the values of each filed in the record

okdtrec◄ If:
       Then: field_ctr="1"
 69  -------   -   -   -   -   -   -   -   -   -   -   -
det_lp ◄ If: field_ctr gt numfield(-)
       Then: goto mkdtrec
 70  -------   -   -   -   -   -   -   -   -   -   -   -
       ◄ If:
       Then: tot_fields[field_ctr]=fieldval(-,field_ctr)
 71  -------   -   -   -   -   -   -   -   -   -   -   -
       ◄ If:
       Then: field_ctr=field_ctr+"1"; goto det_lp

Now create the export detail record:

mkdtrec◄ If: ' ***mkdtrec***
       Then:
 73  -------   -   -   -   -   -   -
       ◄ If:
       Then: detl_ctr="1"

Then I create the export detail record using a delimiter (declared for here
as 'delim'), usually a pipe, to delimit each field and export one record at
a clip containing all the fields pipe-delimited

 74  -------   -   -   -   -   -   -
dtreclp◄ If: ' ***dtreclp***
       Then:
75  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
      ◄ If: detl_ctr eq "1"
      Then: export_detail_rec=tot_fields[detl_ctr]; detl_ctr=detl_ctr+"1";
goto dtreclp
76  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
      ◄ If: detl_ctr le numfield(-)
      Then: export_detail_rec=export_detail_rec{delim{tot_fields[detl_ctr];
detl_ctr=detl_ctr+"1"; goto dtreclp
77  -------   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -
      ◄ If:
      Then: out(1)=export_detail_rec; write out; return

"out" being the alias I gave to my export file

export ascii out = (exp_filename) r=\n

Not quite 2 or 3 lines, but about 10 lines and can be used for any number
of fields.

Now a simple addition to the export detail record using this method would
allow you to append record number, @cd, etc as you deem fit,

I hope that makes sense.

On Mon, May 7, 2012 at 2:18 PM, Brian K. White <brian at aljex.com> wrote:

> On 5/4/2012 5:59 PM, Scott Nelson wrote:
> > On 5/4/2012 2:02 PM, Walter Vaughan wrote:
> >> I know "why" this is a syntax error.
> >> My rant is that it would make an ideal place to keep filepro's record
> >> number in exports
> >>
> >> Then: export ascii psv=(fn) -x
> >> Then: psv(0)=@rn{"|"
> >> Then: psv(1)=1{"|"
> >> ...
> >>
> >> --
> >> walter "pipe separated value" vaughan
> >>
> >
> > Not sure why a field in an export would have a null value...
> >
> > I guess if you Could do psv(@rn)=@rn that would make sense.
>
> I think his point was just that it would be real nice to be able to
> specify export field number starting at 0, so that you could put
> something like record number or the equivalent or copy of the 20 byte
> header etc in field 0 and then the rest of the record could still map
> export fields to the same numbers as the original fields.
>
> If you could put a variable in the export field index, you could divine,
> or at least define, the highest field number plus one and name that O so
> the code could read psv(O) = header/recno/etc followed by psv(1)=1
> psv(2)=2 etc... which would be just about as good for the programmer
> even though the file would be placing the metadata field on the end of
> the records instead of the beginning.
>
> Myself I just avoided ever expecting the export to match especially
> litteraly with any real filepro fields so I've never really missed a
> feature like this but I see how it would be nice sometimes.
>
> For one thing, since there are not just one but several different
> possible things you might want to put into a zeroth field so that you
> could still have export field 1 = filepro field 1, if you're going to
> allow a zero field to support prepending one field, you might as well
> also allow negative fields and prepend as many other fields as you want.
>
> Or allow variables in the export field index which we've wanted forever
> anyways, (since it would simplify many exports to 2 or 3 lines of code
> even if the file has 999 fields). If you could use variables instead of
> literal field numbers to specify the export field number, you could name
> fields anything you want like
> atrn = numfield(-) + "1" ; atcb = atrn + "1"
> psv(atrn)=@rn ; psv(atcb)=@cb
>
> You'd still get to preserve the filepro file's structure in the export,
> yet add more fields to the export that don't exist in the filepro file,
> without even having to manually specify the correct
> highest-real-field-number-plus-one, plus 2 etc...
>
> --
> bkw
> _______________________________________________
> Filepro-list mailing list
> Filepro-list at lists.celestial.com
> Subscribe/Unsubscribe/Subscription Changes
> http://mailman.celestial.com/mailman/listinfo/filepro-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.celestial.com/pipermail/filepro-list/attachments/20120507/f4c08b25/attachment.html 


More information about the Filepro-list mailing list