View Full Version : array help


Romy Huang
01-21-2005, 10:46 AM

I have a invoice form. When fetch each record, I will query this customer have any other invoice overdue. I develop a query and copy the result to array. How to show the array on the form? Any suggestion is appreciated. Thank in advance.

Here is my query and copy to array on OnFetch event:
dim tbl as P
dim qry as P
dim nrecs as N
dim c_no as c

if alltrim(c_no)"""" then
query.description = "Keep Last Invoice"
Query.filter="CUST_NO='"+c_no+"' .and. OVERDUE"=1.0"
qry = tbl.query_create()

nrecs = qry.records_get()
dim i as N
ui_msg_box("test","record: "+str(nrecs),UI_OK)
IF (nrecs " 0) then
dim global invoice1[nrecs] as P
while .not. tbl.fetch_eof()
invoice1[i].cust_no = tbl.cust_no
invoice1[i].invoice_no = tbl.invoice_no
invoice1[i].ship_date = tbl.ship_date
invoice1[i].overdue = tbl.overdue
end while
end if
end if

Romy Huang
01-21-2005, 11:00 AM
invoice form is a set.

Finian Lennon
01-21-2005, 11:20 AM
If what you want to do is show the query results in the form, then I'm not sure why you are doing the array.

If, rather than using the table.query_create() method, you run a form-based query such as:

This:tables:Appoint.filter_expression = this_filter
This:tables:Appoint.order_expression = "LINK1"
pidx = This:tables:Appoint.index_primary_get()
recs = pidx.records_get()

In the above example, "this" is the pointer to the form itself because this script is run in the On Init event of a form.

You can substitute "this" with a formname or a form pointer (such as topparent) if running the query from another location.

Appoint is the parent table of the set on which the form is based.

This_filter is the filter from a statement such as:
this_filter = "CUST_NO='"+c_no+"' .and. OVERDUE=1.0"

recs returns the number of records found so you can reset the form if no records are found and this.resynch() refreshes the form to show the query results. Again, "this" is a pointer and you need to change it according to the location of the query.


Romy Huang
01-21-2005, 11:31 AM
sorry I didn't explain well. I need to have the invoice info. and customer infor. and also how many other invoice the custome didn't pay on the "invoice" form. So when I open a invoice form, I need to query the other invoices this custome didn't pay and show it.

Right now I keep three variables for the oldest invoice the customer didn't pay.

Is there a way I can track all invoices the customer didn't pay? Thanks.

Tom Henkel
01-21-2005, 11:36 AM
Why not just build another set which only shows unpaid invoices??


Romy Huang
01-21-2005, 12:03 PM
Is there a way I can use a button and then show the unpay record.

Romy Huang
01-24-2005, 06:10 AM
I defined array invoices[3]. When I use invoice[i].invoice_no, it has error "invoice not found". But if I use invoice[1].invoice_no, invoice[2].invoice_no,etc.. it works fine. Does any one have any idea? Thank in advance.

Romy Huang
01-24-2005, 06:48 AM
In Help, there is example:
Dim a[1] as P

A[1].name = "Fred"
A[1].city = "Boston"
A[1].age = 23

A[].name = "Tom"
A[..].city = "NY"
A[..].age = 35

but when I use A[..], script error: unexpect value.
Is this in Version 5 or version 6? Thanks

Stan Mathews
01-24-2005, 07:14 AM
Dim a[1] as P
A[1].name = "Fred"
A[1].city = "Boston"
A[1].age = 23

A[].name = "Tom"
A[..].city = "NY"
A[..].age = 35

The a[].name = "Tom" ...............

See Also

Array Functions and Methods, Dot Variables
Supported By
Alpha Five Version 6

Edward Larrabee
01-24-2005, 07:14 AM
Version 6. Take a look at DIM.

Jim Chapman
01-25-2005, 07:42 AM
Hello Ed,

In the examples you linked to, the functions return type is declared as "V". Is this a variant type? I don't find any reference to a "V" type. Also, if this is a variant type, how is this different from "A" type?


Edward Larrabee
01-25-2005, 10:59 AM
"V" stands for Void.