syntax for using a variable in an array

Richard D. Williams richard at appgrp.net
Sun Aug 4 12:23:08 PDT 2013


On 7/31/2013 10:06 AM, Kenneth Brody wrote:
> On 7/31/2013 10:12 AM, tob at b-e-s-t.com wrote:
>> I want to loop through an invoice file and find invoice numbers that have been used and thus invoice numbers that have not been used.
>> The prc below will do it but i do not have the syntax for using a variable in an array correct.
>> Thanks
>>
>> ::dim ni(100000)(8,.0):
> [...]
>> ::ni(iv)="1":  LINE THAT ERRORS
> [...]
>
> The syntax of the "line that errors" is ambiguous, as it could be an attempt
> to define the dummy field "ni".
>
> Change the array name to at least 3 letters.
>
Answer to your question is you can not count available/unavailable 
invoice numbers using the record number.
I am hoping you are not using the record number as your invoice number. 
Very bad move.
It looks like you are using field 2 as the invoice#.
Assuming this is true and you have an index on field 2, try this;

::dim avail(100000)(8,.0);a(7,.0)="":
::dim unavail(100000)(8,.0);u(7,.0)="":
::iv(5,.0)="1"
start:iv eq "99999":goto fini:
::lookup inv = muinv  k=iv i=A -nx:
:not inv:a=a+"1";avail(a)=iv:iv=iv+"1":goto start:
::u=u+"1";unavail(u)=iv:iv=iv+"1":goto start:
fini::msgbox a<"available,"<u<"unavailable.":
:' output total left::

Since I do not know your end game, this is as far as I can go.

Richard D. Williams




More information about the Filepro-list mailing list