Alpha Video Training
Results 1 to 12 of 12

Thread: array help

  1. #1
    Member
    Real Name
    Romy Huang
    Join Date
    Dec 2004
    Posts
    303

    Default array help

    Hi

    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

    c_no=topparent:CUST_NO.text
    if alltrim(c_no)"""" then
    tbl=table.current()
    query.description = "Keep Last Invoice"
    Query.filter="CUST_NO='"+c_no+"' .and. OVERDUE"=1.0"
    Query.order="SHIP_DATE"
    Query.option=""
    qry = tbl.query_create()

    nrecs = qry.records_get()
    dim i as N
    i=1
    ui_msg_box("test","record: "+str(nrecs),UI_OK)
    IF (nrecs " 0) then
    dim global invoice1[nrecs] as P
    tbl.fetch_first()
    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
    i=i+1
    t.fetch_next()
    end while
    end if
    qry.drop()
    end if

  2. #2
    Member
    Real Name
    Romy Huang
    Join Date
    Dec 2004
    Posts
    303

    Default RE: array help

    invoice form is a set.

  3. #3
    "Certified" Alphaholic
    Real Name
    Finian Lennon
    Join Date
    Apr 2000
    Location
    Atlanta, GA
    Posts
    1,805

    Default RE: array help

    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"
    This:tables:Appoint.query()
    pidx = This:tables:Appoint.index_primary_get()
    recs = pidx.records_get()
    this.resynch()

    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.

    Finian

  4. #4
    Member
    Real Name
    Romy Huang
    Join Date
    Dec 2004
    Posts
    303

    Default RE: array help

    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.

  5. #5
    "Certified" Alphaholic Tom Henkel's Avatar
    Real Name
    Tom Henkel
    Join Date
    May 2002
    Location
    New Jersey, USA
    Posts
    1,875

    Default RE: array help

    Why not just build another set which only shows unpaid invoices??

    Tom

  6. #6
    Member
    Real Name
    Romy Huang
    Join Date
    Dec 2004
    Posts
    303

    Default RE: array help

    Is there a way I can use a button and then show the unpay record.

  7. #7
    Member
    Real Name
    Romy Huang
    Join Date
    Dec 2004
    Posts
    303

    Default RE: array help

    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.

  8. #8
    Member
    Real Name
    Romy Huang
    Join Date
    Dec 2004
    Posts
    303

    Default RE: array help

    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

  9. #9
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default RE: array help

    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

  10. #10
    Former Alpha Employee Edward Larrabee's Avatar
    Real Name
    Edward Larrabee
    Join Date
    Nov 2002
    Location
    New Hampshire
    Posts
    1,385

    Default RE: array help

    Version 6. Take a look at DIM.

  11. #11
    "Certified" Alphaholic
    Real Name
    jim chapman
    Join Date
    Apr 2000
    Posts
    1,779

    Default RE: array help

    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?

    Thanks,
    Jim

  12. #12
    Former Alpha Employee Edward Larrabee's Avatar
    Real Name
    Edward Larrabee
    Join Date
    Nov 2002
    Location
    New Hampshire
    Posts
    1,385

    Default RE: array help

    "V" stands for Void.

Similar Threads

  1. array script help
    By Duane Pederson in forum Alpha Five Version 5
    Replies: 2
    Last Post: 07-26-2004, 03:10 PM
  2. String into an array
    By scottly in forum Alpha Five Version 5
    Replies: 4
    Last Post: 01-06-2004, 06:49 PM
  3. array question
    By martinwcole in forum Alpha Five Version 5
    Replies: 2
    Last Post: 07-15-2003, 12:40 AM
  4. Bug in <array>.delete()
    By csda1 in forum Alpha Five Version 5
    Replies: 2
    Last Post: 06-02-2003, 05:59 AM
  5. Using Array ref in Function
    By Nathan White in forum Alpha Five Version 4
    Replies: 0
    Last Post: 11-07-2000, 11:57 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •