Dim arrays & mapping fields

John Esak john at valar.com
Thu Jul 29 11:03:54 PDT 2004



> I'd seen this in the context Ken mentions, @W*F code, but I'd rarely
> seen it in mainline code, so it stonkered me for a while recently.
> Ken?  Does the cross-ref generator catch these?  ISTR that it missed it.
>
> @AF serves as an "array index" -- it tells you *which* of the associated
> fields in the group is the one you're matched on; which one is the
> current "row" of the "table" within the record you're working on.
> This true even if those associated fields are not in sequential
> real-field-number order in the table (correct, Ken?), though @FD is
> much less useful there (it's primary purpose being to give you an array
> index which you can use to index arrays mapped to other paired groups
> of associated fields -- letting you get the quantity and price of the
> current line of the invoice form after you figure out which item you're
> processing).
>
> But yes, if your fields are not in order, you're going to have to slog
> through them one by one.
>
> Cheers,
> -- jra
> --
> Jay R. Ashworth

Well, I'm not Ken obviously, but I can respond to part of this.

The code would work with the full associated field group system... in other
words not just pair groups. There are a0) through a9) tow work with. (a0) is
the same as a) ).  Anyway, you can do this:

@wlfa)    if:
        then: a9)=a3) * a8);  display; end

Which might mulitply the price times the quantity to provide an extension
when you leave a description field...  Or you can do something more specific
by overlaying an array over an associated fiedl group. (in which case, the
fields _must_ be contiguous. So that:


      5.  a) item#      5   .0
      6.  a) item#      5   .0
      7.  a) item#      5   .0
      8   a) item#      5   .0

and   then: dim array[4]:5

would allow you to do:


  @wlfa)  if:
        then: ext[@af]=prc[@af] * qty[@af];  display;  end

(assuming those other arrays were also defined over contiguous groups of
real fields, you can essentially write one line of code to handle a
screenful of line items.

Lost of way to skin the cat.

John

P.S. - Obviously, @af returns the value of the associated field you have
just left in this case.



More information about the Filepro-list mailing list