filepro INDIRECT function

Kenneth Brody kenbrody at bestweb.net
Tue May 23 14:28:03 PDT 2006


Quoting Enrique Arredondo (Tue, 23 May 2006 14:01:52 -0700):
[...]
> If you have on excel..... A1 =  1234    and on B1 = A1    and on C1=
> indirect(B1)   the C1 cell will show 1234.
>
> so in filepro language....
>
> import ascii imp(...... so  imp(1) = 1   .... and 1 = "Porsche" in the
> database, so If I want to export it to a csv file, What should I use
> instead
> of  :
>
> export ascii out(......       out(1)=indirect(imp(1))   ... and out(1)=
> Porsche.
>
> Do I make sense ?

So imp(1) contains the field number that you want to export, correct?

One way is to alias an array to the current record:

    dim fields[999]:1

where "999" is really the number of fields in the record.  Then, you
can have:

    out(1) = fields[imp(1)]

Of course, you'll want to bounds-check imp(1) first.

Another way is via the FIELDVAL() function:

    out(1) = fieldval(-,imp(1))

Note that the second method has some advantages.  First, you don't
need to bounds-check imp(1), as invalid field numbers will simply
return a null string ("").  Second, it can contain a dummy field
name such as "aa", or system fields such as "@rn", and still work.
If you want to make sure that only real fields can be accessed,
bounds-check it to be greater than zero and less than or equal to
999.

--
KenBrody at BestWeb dot net        spamtrap: <g8ymh8uf001 at sneakemail.com>
http://www.hvcomputer.com
http://www.fileProPlus.com


More information about the Filepro-list mailing list