variable for import field number loop

Jay R. Ashworth jra at baylink.com
Thu Mar 13 10:00:09 PDT 2008


On Thu, Mar 13, 2008 at 09:35:31AM -0700, Scott Nelson wrote:
> Is there a way to use a variable to count through the field numbers on 
> an import?  Such as
> 
> :import new = importfile r=\n f=;
> 
> :x(2,.0)="1"
> 
> :aa=new(x); gosub dothis; etc
> 
> 
> There are hundreds of fields in each line and I would prefer not to do:
> 
> if: x eq "1"
> then: aa=new(1)
> 
> and so on.

On inspecting your question more closely, I see that the real question
is not "how do I simulate a for/next loop, since filePro doesn't
provide them", but but the related question "how do I loop across the
tagged fields provided by an IMPORT, since the argument of the
pseudo-array is a literal, not a variable, in its syntactical context."

The obvious -- the standard way to dereference a variable into a
literal context -- is to surround it with parens, as in the filename of
a lookup.

That may not help here, as it leaves you with 

::aa=new((ii)):

Since the (varname) dereferencing is apparently done by each command's
individual lexer rather than by the parser (Ken wil no doubt correct me
if I'm wrong here), there's no guarantee that this will work, but it
would be what I'd try -- there doesn't seem to be any *other* obvious
answer.

Cheers,
-- jra
-- 
Jay R. Ashworth                   Baylink                      jra at baylink.com
Designer                     The Things I Think                       RFC 2100
Ashworth & Associates     http://baylink.pitas.com                     '87 e24
St Petersburg FL USA      http://photo.imageinc.us             +1 727 647 1274

	     Those who cast the vote decide nothing.
	     Those who count the vote decide everything.
	       -- (Joseph Stalin)



More information about the Filepro-list mailing list