Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Advice....Where to put TBL(Close)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Advice....Where to put TBL(Close)

    Hello,

    I know I need to place a tbl(close) on the Invoice and Customer File, but unsure of the best place.

    Below is the code for the script I use...

    'Date Created: 13-Mar-2009 02:26:53 AM
    'Last Updated: 19-Apr-2009 02:49:05 PM
    'Created By : Ryland
    'Updated By : Ryland
    DIM global_var_A as c
    DIM GLOBAL user as C
    DIM GLOBAL pword as C
    DIM GLOBAL level as C
    DIM GLOBAL varC_result as C
    dim global try as n
    dim global way as c
    dim ans as n
    dim time_in as c
    dim tbl as p
    dim tbl_1 as p
    dim qry as p
    dim qry_1 as p
    dim recs as n
    dim recs_1 as n
    dim global user_level as c
    DIM global v_personnel as c
    dim XDialogStyle as p

    user=""
    pword=""
    level=""
    user_level=""
    v_personnel=""


    ok_button_label = "&Verify_ID"
    cancel_button_label = "&Manual"
    Delete XdialogStyle

    XDialogStyle.AccentColor = "White"
    XDialogStyle.Color = "#51+102+255"
    varC_result = ui_dlg_box(" Please Scan Your CAC ",<<%dlg%
    {Windowstyle=Gradient Radial Bottom Right}
    {region}
    SCAN CAC:| [%p%.30user];

    {endregion};
    {line=1,0};
    {region}
    {justify=center}
    <15=ok_button_label!Verify_ID> <15=cancel_button_label!Manual>
    {endregion};
    %dlg%)
    scan_id=upper(scan_id)

    if varC_result="Manual" then
    user="Manual User login"
    script_play("login_script_1")
    end
    end if


    tbl=table.open("customer") ' table open here
    query.filter="scan_id = "+s_quote(user)
    query.order=""
    query.options="T"
    qry=tbl.query_create()
    recs=qry.records_get()

    tbl_1=table.open("invoice_items") ' another table open here
    query.filter="scan_id = "+s_quote(user)
    query.order=""
    query.options="T"
    qry_1=tbl_1.query_create()
    recs_1=qry_1.records_get()


    if recs = 0 then
    msgbox("CAC ID Not on Alpha-Roster, Please Re-enter")
    script_play("Main_Menu")
    end if


    if recs > 0 .and. (tbl.level = "Supervisor" .or. tbl.level = "Commander" .or. tbl.level = "Custodian Primary" .or. tbl.level = "Custodian Alternate")
    v_personnel= tbl.customer_id
    user_level = tbl.Level
    msgbox("Commander/Supervisor/Custodian Issue")
    script_play("Invoice_Script")

    end if

    if recs > 0 .and. (tbl.level = "A-Roster Customer" .or. tbl.level = "Temporary Customer") then
    v_personnel= tbl.customer_id

    user_level = tbl.Level
    'msgbox("Continue to Tool Issue", v_personnel)

    script_play("Invoice_Script")


    end if

    end


    Thanks, Ryland

    #2
    Re: Advice....Where to put TBL(Close)

    It's table.close() and the best place to put it is when you no longer need to access the table.

    Comment


      #3
      Re: Advice....Where to put TBL(Close)

      Thanks, I placed the Table.close() just before the ned statement of the script. However, what is driving me crazy is that when I validate the user credentials, for the first time, it creates 2 header records when I call the Invoice Routine (a variation from the Aplha Sports). The default transaction is 100, so that's cool. but as soon as I open the "Tool Issue" screen, it creates 2 additional header records. I thought that the close table missing from the script could be causing it.

      Darned if I can find it, but I notice that when I go to open the revisted invoice sreen from the login, I see the hourglass cycle two times whivh creates header records 101 and 102, and then displays invoice 103 ready for input. I keep thinking that it is in the script:

      'Date Created: 13-Mar-2009 02:26:53 AM
      'Last Updated: 20-Apr-2009 04:38:30 PM
      'Created By : Ryland
      'Updated By : Ryland
      DIM global_var_A as c
      DIM GLOBAL user as C
      DIM GLOBAL pword as C
      DIM GLOBAL level as C
      DIM GLOBAL varC_result as C
      dim global try as n
      dim global way as c
      dim ans as n
      dim time_in as c
      dim tbl as p
      dim tbl_1 as p
      dim qry as p
      dim qry_1 as p
      dim recs as n
      dim recs_1 as n
      dim global user_level as c
      DIM global v_personnel as c
      dim XDialogStyle as p

      user=""
      pword=""
      level=""
      user_level=""
      v_personnel=""


      ok_button_label = "&Verify_ID"
      cancel_button_label = "&Manual"
      Delete XdialogStyle

      XDialogStyle.AccentColor = "White"
      XDialogStyle.Color = "#51+102+255"
      varC_result = ui_dlg_box(" Please Scan Your CAC ",<<%dlg%
      {Windowstyle=Gradient Radial Bottom Right}
      {region}
      SCAN CAC:| [%p%.30user];

      {endregion};
      {line=1,0};
      {region}
      {justify=center}
      <15=ok_button_label!Verify_ID> <15=cancel_button_label!Manual>
      {endregion};
      %dlg%)
      scan_id=upper(scan_id)

      if varC_result="Manual" then
      user="Manual User login"
      script_play("login_script_1")
      end
      end if


      tbl=table.open("customer")
      query.filter="scan_id = "+s_quote(user)
      query.order=""
      query.options="T"
      qry=tbl.query_create()
      recs=qry.records_get()

      'tbl_1=table.open("invoice_items")
      'query.filter="scan_id = "+s_quote(user)
      'query.order=""
      'query.options="T"
      'qry_1=tbl_1.query_create()
      'recs_1=qry_1.records_get()


      if recs = 0 then
      msgbox("CAC ID Not on Alpha-Roster, Please Re-enter")
      script_play("Main_Menu")
      end if


      if recs > 0 .and. (tbl.level = "Supervisor" .or. tbl.level = "Commander" .or. tbl.level = "Custodian Primary" .or. tbl.level = "Custodian Alternate")
      v_personnel= tbl.customer_id
      user_level = tbl.Level
      msgbox("Commander/Supervisor/Custodian Issue")
      script_play("Invoice_Script")

      end if

      if recs > 0 .and. (tbl.level = "A-Roster Customer" .or. tbl.level = "Temporary Customer") then
      v_personnel= tbl.customer_id

      user_level = tbl.Level
      'msgbox("Continue to Tool Issue", v_personnel)
      script_play("Invoice_Script")


      end if
      table.close() ' added table close
      end

      Comment


        #4
        Re: Advice....Where to put TBL(Close)

        Code:
        if recs > 0 .and. (tbl.level = "Supervisor" .or. tbl.level = "Commander" .or. tbl.level = "Custodian Primary" .or. tbl.level = "Custodian Alternate")
        v_personnel= tbl.customer_id
        user_level = tbl.Level
        msgbox("Commander/Supervisor/Custodian Issue")
        [COLOR="Red"]script_play("Invoice_Script")[/COLOR]
        end if
        
        if recs > 0 .and. (tbl.level = "A-Roster Customer" .or. tbl.level = "Temporary Customer") then
        v_personnel= tbl.customer_id
        
        user_level = tbl.Level
        'msgbox("Continue to Tool Issue", v_personnel)
        [COLOR="Red"]script_play("Invoice_Script")[/COLOR]
        
        
        end if
        [COLOR="Red"]tbl.close()[/COLOR] ' added table close - need to use the same pointer used in the table.open() command
        You call "Invoice_Script" twice, is this what is creating your duplicate records? I also noted a change in the <table>.close() statement.
        Andrew

        Comment


          #5
          Re: Advice....Where to put TBL(Close)

          Hi,

          The two run scripts conditional and only one that matches those should execute. (i'll add a message and make sure). As far as the tbl.close, I just re-added the generic table.close() seeing if that would make a difference..

          Comment


            #6
            Re: Advice....Where to put TBL(Close)

            Originally posted by [email protected] View Post
            As far as the tbl.close, I just re-added the generic table.close() seeing if that would make a difference..
            There is no such code - 'generic table.close()'
            Al Buchholz
            Bookwood Systems, LTD
            Weekly QReportBuilder Webinars Thursday 1 pm CST

            Occam's Razor - KISS
            Normalize till it hurts - De-normalize till it works.
            Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
            When we triage a problem it is much easier to read sample systems than to read a mind.
            "Make it as simple as possible, but not simpler."
            Albert Einstein

            http://www.iadn.com/images/media/iadn_member.png

            Comment


              #7
              Re: Advice....Where to put TBL(Close)

              A few generic comments about closing tables...

              First, as others have said, there is no "generic table.close()". The help file says this:
              The <TBL>.CLOSE() method closes the currently open table referenced by the <TBL> object pointer.
              Note that <TBL> is a pointer. It must be the same pointer that was used to open (or "get()") the table initially. (There are actually multiple ways to "get" a table pointer but I won't go into that here.)

              When to use <tbl>.close()

              1. Alpha says they try to close all tables when a script ends. This would imply that <tbl>.close() isn't necessary. Based on my experience, sometimes that's true - in fact, most times it's true - but sometimes it's not. I've never been able to determine why it works sometimes and not others so my rule is ALWAYS close all open tables before ending a script. I even created a routine to check for that somewhere but I don't know what ever happened to it.

              2. This is really a clarification of the "always close all open tables" statement above. Since a script can end either at the last line or any "END" statement (or EXIT FUNCTION statement in a function) in the script, sometimes there will be multiple "close" commands for the same table - one in each IF or SELECT statement where the script (or function) might end.

              3. Closing or not closing a table should have very little affect within the script where it was opened.

              4. There are exceptions to everything - including #3. I had one very complicated script where multiple tables were opened simultaneously. Somewhere in there I ran into a data "corruption" problem (I don't remember the details of the "corruption") that never made any sense. I studied that script a lot trying to find something wrong with my original code but found nothing. The only solution was to get the record number and close the table before a certain part of the script was run then re-open the table afterwards and reposition the pointer to the original record. Unfortunately I don't recall the details but it seemed to have something to do with opening and editing too many tables at once. I only mention this in case someone else runs into a problem that makes no sense when a lot of tables are being edited at once. It's not a likely occurence and maybe it wouldn't even have been an issue in the latest versions. It only happened to me once in the past 18 years or so - probably in A5v5.

              A bit of further clarification on #1: The script will end without any errors even if a table isn't specifically closed in the script. However, you may have trouble opening that table again in another script. This can make it difficult to troubleshoot because it isn't obvious that the problem actually originated in some other script that has nothing to do with the current action.
              Last edited by CALocklin; 04-21-2009, 12:28 AM.

              Comment


                #8
                Re: Advice....Where to put TBL(Close)

                Hi Cal,

                Originally posted by CALocklin View Post
                ....so my rule is ALWAYS close all open tables before ending a script.
                Small correction to that rule.

                In most cases, you should only close what you have opened. E.g. If you get the pointer for the current table( e.g. ptr=table.current() ), or are passed a pointer to a table, you don't normally close that table.

                Good programming practice restores/leaves the environment of variables and pointers the same as when the script started (except for ones the script is intended to change). Thus, if I have a function that is passed a table name, if it was opened before I started using it, I leave it open at the end of the function. If it was not opened initially, I will normally close it at the end. The exception is, when I know I have multiple calls, I may leave it opened until the last one, and that is often done by passing a flag saying to close the table or keep it open.
                Regards,

                Ira J. Perlow
                Computer Systems Design


                CSDA A5 Products
                New - Free CSDA DiagInfo - v1.39, 30 Apr 2013
                CSDA Barcode Functions

                CSDA Code Utility
                CSDA Screen Capture


                Comment


                  #9
                  Re: Advice....Where to put TBL(Close)

                  In addition to the tbl.close() you most likely want to close the other table you opened with tbl_1.close()....most likely where Andrew placed the former right before your end statement.

                  Placing a debug(1) in may aid in determining where an additional record is being added--in the script provided and also in the called script "Invoice_Script" (more likely suspect).
                  Mike
                  __________________________________________
                  It is only when we forget all our learning that we begin to know.
                  It's not what you look at that matters, it's what you see.
                  Henry David Thoreau
                  __________________________________________



                  Comment


                    #10
                    Re: Advice....Where to put TBL(Close)

                    Originally posted by csda1 View Post
                    In most cases, you should only close what you have opened. E.g. If you get the pointer for the current table( e.g. ptr=table.current() ), or are passed a pointer to a table, you don't normally close that table.
                    Good point. In fact, attempting to close a table that was opened with table.get() or table.current() should generate an error message because you can't close a table in an open form without closing the form first. (And, of course, once the form is closed, so is the table - which means you still can't use <tbl>.close() without generating an error.)

                    IOW - If it wasn't opened with Table.Open() don't try to close it. And, if it wasn't opened with Table.Open() in the current script, you shouldn't try to close it either. Disclaimer: As previously mentioned, there can always be exceptions but in this last case they would probable be due to poor coding techniques.

                    Comment


                      #11
                      Re: Advice....Where to put TBL(Close)

                      Just getting back to this thread.
                      Hmmmm!
                      Why do I get the feeling that we are playing in the wrong stadium? Like playing football in a basketball court?
                      Thanks to you Ryland!
                      You asked: where should I put table.close()?
                      Well, you got an avalanche of responses on table.close().
                      You surmised that the problem you are having is due to a misplaced table.close() and railroaded yourself.

                      The problem you seem to be having is a duplicate header whatever that is. Not having your table and the other script, it's all abstract but I am willing to bet the lonely goat I have on the fact that the problem is in your IF statements.
                      In your script, you have:
                      if condition1 .OR. condition2...etc
                      do this
                      end if

                      if condition3.OR.condition4
                      do this
                      end if

                      I am willing to bet my measly goat that there are more than one condition that applies to the user and hence you end up with more than one "Header" especially so and given the fact that none of these if statements terminate the script.

                      Comment


                        #12
                        Re: Advice....Where to put TBL(Close)

                        Hi Ryland,

                        So the choice is yours about where to close the table, but I always do it earlier than later. Make sure you do it for all tables and other system handles you have opened as well in the code.

                        It leaves the tables in a closed state sooner, meaning should the code error out, system crash, or just some other user needs exclusive control, it has a higher chance of being available and doesn't leave half-written cache's (which are always flushed (written) at table closes).

                        Here is my version of your last piece of code with comments you should read.

                        Code:
                        ' tbl.close() could be placed at a common place (at the end of the code for this case)
                        ' but as long as every possible exit from the script is covered to close what the code opened
                        ' you are OK
                        '
                        ' Also note the IF-ELSE IF-ELSE-END IF structure 
                        ' (this amounts to the same thing as CASE-SELECT if you prefer that format)
                        if recs = 0 then
                            msgbox("CAC ID Not on Alpha-Roster, Please Re-enter")
                        ' If "Main_Menu" is this script, it potentially could call itself repeatedly
                        ' in a way that never clears the code stack that is being built up.  
                        ' In that case, just jump to the top of this code
                            tbl.close()    ' close table as soon as it is no longer needed (conserves use of table on network)
                                        ' Could be before msgbox(), if no values from tbl are needed to pass to for msgbox()
                                        ' and before script_play, as it will no longer be needed.
                                        ' If still needed for script_play("Main_Menu"), then put it on the line afterwards
                            script_play("Main_Menu")
                        else if (recs > 0) .and. (tbl.level = "Supervisor" .or. tbl.level = "Commander" .or. tbl.level = "Custodian Primary" .or. tbl.level = "Custodian Alternate")
                            v_personnel= tbl.customer_id
                            user_level = tbl.Level
                            msgbox("Commander/Supervisor/Custodian Issue")
                            tbl.close()
                            script_play("Invoice_Script")
                        else if recs > 0 .and. (tbl.level = "A-Roster Customer" .or. tbl.level = "Temporary Customer") then
                            v_personnel= tbl.customer_id
                        
                            user_level = tbl.Level
                        '    msgbox("Continue to Tool Issue", v_personnel)
                            tbl.close()
                            script_play("Invoice_Script")
                        Else
                            ' This takes care to cleanup the code for all other cases by closing the tables opened
                            tbl.close()
                        end if
                        end
                        Regards,

                        Ira J. Perlow
                        Computer Systems Design


                        CSDA A5 Products
                        New - Free CSDA DiagInfo - v1.39, 30 Apr 2013
                        CSDA Barcode Functions

                        CSDA Code Utility
                        CSDA Screen Capture


                        Comment

                        Working...
                        X