Alpha Video Training
Results 1 to 14 of 14

Thread: Closing forms

  1. #1
    Member
    Real Name
    Lowell Wardlow
    Join Date
    Apr 2000
    Location
    Texas
    Posts
    185

    Default Closing forms

    Can any one tell my why this doesnt work, and suggest what
    will ?

    I have a menu which loads and hides/shows a number of forms.
    I am looking for a way to automatically close any open forms
    when exiting.

    ----------------------------------------------------
    ' CLOSE ANY/ALL OPEN FORMS
    dim ptr as p
    dim fil_name as c


    fil_name = :A5.form_enum("")

    while fil_name ""
    ptr=obj(fil_name)

    if is_object(ptr)
    trace.writeln(fil_name)
    ptr.close()
    end if

    fil_name = :A5.form_enum(fil_name)
    end while
    end
    ---------------------------------------------
    Lowell

  2. #2
    Volunteer Moderator Peter.Greulich's Avatar
    Real Name
    Peter Greulich
    Join Date
    Apr 2000
    Location
    Boston, MA
    Posts
    11,643

    Default RE: Closing forms

    I think your script may have several mistakes. Try this:
    ----------------------------------------------------
    ' CLOSE ANY/ALL OPEN FORMS
    dim ptr as p
    dim fil_name(20) as c

    fil_name = :A5.form_enum("")

    i=1

    while fil_name ""
    ptr=obj(fil_name(i))

    if is_object(ptr)
    trace.writeln(fil_name)
    end if

    i=i+1
    fil_name = :A5.form_enum(fil_name(i))
    end while
    ptr.close()
    end
    ---------------------------------------------
    Look at the example on Page 356 of the xbasic manual.

  3. #3
    Volunteer Moderator Peter.Greulich's Avatar
    Real Name
    Peter Greulich
    Join Date
    Apr 2000
    Location
    Boston, MA
    Posts
    11,643

    Default RE: Closing forms

    ...probably should be:

    while fil_name(i) ""
    ptr=obj(fil_name(i))

    if is_object(ptr)
    trace.writeln(fil_name(i))
    end if





    ....but untested...

  4. #4
    Volunteer Moderator Peter.Greulich's Avatar
    Real Name
    Peter Greulich
    Join Date
    Apr 2000
    Location
    Boston, MA
    Posts
    11,643

    Default RE: Closing forms

    ptr.close() is incorrect. Ptr is a variable - you can't "close" it.

  5. #5
    Member
    Real Name
    Daniel Weiss
    Join Date
    May 2000
    Location
    Monsey, NY
    Posts
    506

    Default RE: Closing forms

    I once wrote the following script to open forms in the background, the reason I did that then was because alpha did not have yet the shadow option and it took a long time open a form each time the user wanted to use it.
    You can use the same to close any open forms

    dim shared frm_invoice_entry as p
    dim shared frm_customer_entry as p
    dim shared frm_invoicing_reports as p
    dim shared frm_payments_entry as p

    if .not.is_object("INVOICE ENTRY")
    frm_invoice_entry = form.load("INVOICE ENTRY")
    frm_invoice_entry.index_set("invno")
    frm_invoice_entry.show()
    end if

    if .not.is_object("CUSTOMER ENTRY")
    frm_customer_entry = form.load("CUSTOMER ENTRY")
    frm_customer_entry.index_set("custid")
    frm_customer_entry.show()
    end if

    if .not.is_object("INVOICING REPORTS")
    frm_invoicing_reports = form.load("INVOICING REPORTS")
    frm_invoicing_reports.index_set("invno")
    frm_invoicing_reports.show()
    end if

    if .not.is_object("PAYMENT ENTRY")
    frm_payments_entry = form.load("PAYMENT ENTRY")
    frm_payments_entry.index_set("open_inv")
    frm_payments_entry.show()
    end if


    END
    enjoy
    Dan

  6. #6
    Member
    Real Name
    Lowell Wardlow
    Join Date
    Apr 2000
    Location
    Texas
    Posts
    185

    Default RE: Closing forms

    Dan -
    Thanks for your response. I know this will work, but it
    requires explicit coding for each form that you have opened.

    What I am actualy looking for is a generec routine using an indirect addressing scheme, which will allways find ALL open forms/tables, and close them. Have tried using the enum() function, also .close(), where is derived from tbl = table.current(count). Cant get either to work.

    Lowell

  7. #7
    Volunteer Moderator Peter.Greulich's Avatar
    Real Name
    Peter Greulich
    Join Date
    Apr 2000
    Location
    Boston, MA
    Posts
    11,643

    Default RE: Closing forms

    Lowell, I must have been punch drunk. *My* script had too many mistakes. My apologies. the following has been tested and works:

    ''XBasic
    'CLOSE ANY/ALL OPEN FORMS

    dim fil_name as c
    dim ptr as C

    fil_name = :A5.form_enum("")

    while fil_name ""


    ptr=left(fil_name,at("@",fil_name)-1)

    if is_object(ptr)
    trace.writeln(ptr)
    eval(ptr + ".close()")
    end if

    fil_name = :A5.form_enum(fil_name)
    end while
    end

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

    Default RE: Closing forms

    Hi Lowell,

    The reason you are having trouble is that fil_name contains the full name and path of the saved form in the data dictionary, such as 'form_name@c:program files......table_name.ddd'

    The obj(fil_name) function isn't able to handle the full path direction and so will never give you a pointer.

    The following syntax should work as the word() function sees a colon as a word seperator:

    fil_name = :A5.form_enum("")

    while fil_name ""
    vword = word(fil_name,1)
    vobj = left(vword, len(vword)-2)
    ptr=obj(vobj)

    ' etc etc.

    This is kind of clumsy, but this should get you just a character string containing the name of the form only and allow your syntax to work. HOWEVER
    you are just enumerating through the form names in the data dictionary and that doesn't necessarily give you the names of the open form ie: if you have a form named 'aForm' and you open a second instance of the form A5 will name the second instance 'aForm0'. Enumerating through the data dictionary will not pickup the second instance of the form. I don't know any way of finding all open forms. This shouldn't be a trick as A5 knows what is open, but I don't know of any tools where we can get this info.

    Anyone out there know of a way?

    Good luck,
    Jim





  9. #9
    Member
    Real Name
    Lowell Wardlow
    Join Date
    Apr 2000
    Location
    Texas
    Posts
    185

    Default RE: Closing forms

    Never could get any of the above to work the way I envisioned.

    However, :A5.close() does seem to close EVERYTHING - at least, I have had no errors when shutting down my server if
    I closed the application (database) using it.

    Thanks -

    Lowell

  10. #10
    Member
    Real Name
    Lowell Wardlow
    Join Date
    Apr 2000
    Location
    Texas
    Posts
    185

    Default RE: Closing forms

    Spoke too soon - A5.close() produces an error, have to reboot each time.

    Lowell

  11. #11
    Volunteer Moderator Peter.Greulich's Avatar
    Real Name
    Peter Greulich
    Join Date
    Apr 2000
    Location
    Boston, MA
    Posts
    11,643

    Default RE: Closing forms

    I have problems with a5.close() too.

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

    Default RE: Closing forms

    Peter:

    Are you running Windows 2000 or ME or Win 98SE?

    I never had a problem with A5.Close() under NT but have had a number of annoying issues under Win 2K. In th case of A5.Close() I found that when run at the end of certain scripts A5 crashed hard.

    I ended up having to separate the A5.Close out into the oninit of a form that was called just for that purpose.

    Finian

  13. #13
    Member
    Real Name
    Lowell Wardlow
    Join Date
    Apr 2000
    Location
    Texas
    Posts
    185

    Default RE: Closing forms

    Finian - running WIN98 - I have stopped using this. Finaly got a routine to find/close all forms.

    Thanks
    Lowell

  14. #14
    Volunteer Moderator Peter.Greulich's Avatar
    Real Name
    Peter Greulich
    Join Date
    Apr 2000
    Location
    Boston, MA
    Posts
    11,643

    Default RE: Closing forms

    Finian:

    Win95/98. A5.close() crashes hard aboout half the time in an automatic network shutdown script. Your idea is worth a try.



    PS I have the fantasy (maybe not?) that ver. 5 will cure many of these little glitches.

Similar Threads

  1. Closing Multiple Forms
    By Phil Rolf in forum Alpha Five Version 5
    Replies: 7
    Last Post: 12-04-2002, 06:04 PM
  2. opening/closing forms,etc
    By Daniel Earley in forum Alpha Five Version 5
    Replies: 2
    Last Post: 10-23-2002, 02:31 PM
  3. Closing forms
    By CALocklin in forum Alpha Five Version 5
    Replies: 0
    Last Post: 07-27-2002, 06:30 AM
  4. Closing Forms
    By GregOnline in forum Alpha Five Version 4
    Replies: 3
    Last Post: 12-18-2001, 02:30 PM
  5. Closing a series of forms
    By Greg Fong in forum Alpha Five Version 4
    Replies: 14
    Last Post: 08-15-2001, 03:15 PM

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
  •