syntax for copying fields using variable

Bruce Easton bruce at stn.com
Tue Nov 24 10:21:19 PST 2015


On 11/24/15 12:45 PM, Tim OBrien via Filepro-list wrote:
> Using fp 5.0.13R4 on Centos 5.4
> I wanted to use the syntax below to copy a number of fields from one record to another but get a syntax error.
> Is this possible?
> Thanks
>   
> After opening the two records without any issue
> lookup ipd = invprod@ r=free -e
> lookup form = f837@ k=kk i=a -nx
>   
> I wanted to copy fields 80-120 and 201-400 using a variable loop
>   
> ct(3,.0)="79"
>   
> nxct1 ? If: ?
>   Then: ct=ct+"1" ?
> 1564 ------- - - - - - - - - - - - - - - - -
>   ? If: ct lt "120" ?
>   Then: ipd(ct)=form(ct);goto nxct1 ?
> 1565 ------- - - - - - - - - - - - - - - - -
>   ? If: ?
>   Then: ct="201" ?
> 1566 ------- - - - - - - - - - - - - - - - -
> nxct2 ? If: ?
>   Then: ct=ct+"1" ?
> 1567 ------- - - - - - - - - - - - - - - - -
>   ? If: ct lt "401"
>   Then: ipd(ct)=form(ct);goto nxct2
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://mailman.celestial.com/pipermail/filepro-list/attachments/20151124/d897ee95/attachment.html>
> _______________________________________________
> Filepro-list mailing list
> Filepro-list at lists.celestial.com
> Subscribe/Unsubscribe/Subscription Changes
> http://mailman.celestial.com/mailman/listinfo/filepro-list
>
Tim, you need to reference the lookup fields using arrays if you need to 
want to loop thru to assign.  Also, 'form' is a command so I would 
advise avoiding that as an alias name.

**Let's assume you rename the alias for the second lookup to "frm".**  
Then right after the lookups, you should first, for any lookup where 
you've used the -n flag, tell filepro what you want to do if the lookup 
fails - for instance:

If: not frm
Then:  errorbox "couldn't match on "<kk<" for the f837 file"; end

Then right after that, you can define arrays against the lookup files:

Then: dim aripd(###):ipd(1)
Then dim arfrm(###):frm(1)

^^ where ### should be replaced for each array declaration to the max 
field number in each file - and you would not enclose that in quotes - 
i.e., "dim aripd(600) , if that file has 600 fields in it

Then below that you may be able to get the code you show to work, but 
you'll need to change the references of the aliases to array element 
references - so "ipd(ct)" would become "aripd[ct]" and "frm(ct)" would 
become "arfrm[ct]".
(I like to use brackets when referencing array elements to make things 
obvious.)


--Bruce




---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus



More information about the Filepro-list mailing list