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

tbl.zap() not working for me

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

    tbl.zap() not working for me

    Hello,

    I have a need to populate a table (Notecount) starting with the table being empty. I am using the following script which isn't emptying the table for me. Any assistance would be appreciated.

    Code:
    dim tbl as P
    dim safety as L
    
    tbl = table.open("Notecount")
    safety = .t.
    tbl.zap(safety)
    tbl.close()
    Thanks,

    Mike W
    Mike W
    __________________________
    "I rebel in at least small things to express to the world that I have not completely surrendered"

    #2
    Re: tbl.zap() not working for me

    The "zap" requires exclusive access. (It doesn't have to be opend with File_rw_exclusive as long as the access is exclusive.) My guess is that there's another copy of the table already open.

    Try either opening it with:
    Code:
    [COLOR=blue]tbl = table.open("Notecount",FILE_RW_EXCLUSIVE)[/COLOR]

    or, better yet, precede the above with:
    Code:
    [COLOR=blue]IF table.inuse("Notecount")
        ui_msg_box( "NOT EXCLUSIVE", "your message here", 16 )
        END'
    END IF[/COLOR]

    Comment


      #3
      Re: tbl.zap() not working for me

      Cal,
      Thank for steering me. The syntax is table.in_use(). So that's likely the answer. My script operates great one time but then not exclusive. Table.enum_open() lists it as open.

      Code:
      dim tbl as P
      dim safety as L
      
      tbl = table.open("Notecount")
      safety = .t.
      tbl.zap(safety)
      tbl.close()
      A fundemental question I guess I thought I knew the answer to and should know but I guess I don't. Doesn't the line tbl.close() at the scripts end close the table session? How do I close the table so it can be 'not open' and available for use?

      Mike W
      Mike W
      __________________________
      "I rebel in at least small things to express to the world that I have not completely surrendered"

      Comment


        #4
        Re: tbl.zap() not working for me

        A fundemental question I guess I thought I knew the answer to and should know but I guess I don't. Doesn't the line tbl.close() at the scripts end close the table session?
        Yes.
        How do I close the table so it can be 'not open' and available for use?
        That should do it. HOWEVER, I believe I have seen A5 leave some tables open after certain operations. This may be one of them - I'm not sure and I can't even swear that it wasn't "my fault" when it happened.

        All I can recommend is to check very carefully to be sure the table isn't being opened somewhere else.

        Edit - perhaps the zap() isn't finished by the time you try to close it??? Maybe a xbasic_wait_for_idle() after the zap will help??? (I don't have a lot of hope for this but it shouldn't hurt.)

        Comment


          #5
          Re: tbl.zap() not working for me

          Cal,
          Thanks for you thoughts. I had already tried xbasic_wait_for_idle() , x 10 even. Didn�t help. �End� worked, though, so there must be something in the overlap of script execution that inhibits the tbl.close() event.

          Arg! My application distributes NOTES one or more of 13-15 different department �Areas�. Each person (unique loginID) is responsible to sign off reading the messages for each Area they have involvement with. This part of the application generates a numeric summary of their unread messages.

          I have this writing to a table (the one I want empty for the purposes of being temporary) with 2 fields, Area and Notecount. It starting with a Lookup() to a table with the list of Areas, This generates the variable vareav and uses the following filter to enumerate the number of records in each area they have not signed off on. The signature field is a Memo field (100 + employees).

          Code:
          a5_get_records_in_query("Notes", s_quote((Var->vloginid))+" !$ signature .and. "+s_quote(Var->vareav)+" $ Area")
          After the table is created, I have it displayed as a List-List dialog box with OnDoubleClick fetching the Notes of that particular Area for review and sign off..

          This temporary table that I cannot ZAP and Close is a major barrier to this entire scheme.

          Arg! I guess another approach is needed� And this up until now was working sweet!

          Mike W
          Mike W
          __________________________
          "I rebel in at least small things to express to the world that I have not completely surrendered"

          Comment


            #6
            Re: tbl.zap() not working for me

            Instead of closing it after zapping, why not just populate the table while it's open? I've done that many times without problems.

            If the "zap" isn't in an appropriate place, just move it so that it is immediately before the "populate" routine.

            Comment


              #7
              Re: tbl.zap() not working for me

              table.zap() is "fineky". I had trouble with it before.

              Here are few better alternatives:

              a-Create a temp table with xbasic, then delete it altogether, or

              b-Duplicate the table (not the records) and delete the one with the records, or

              c-If you do not mind shutting down all other tables, before running your table.zap() script, use: a5_forceclosetables() , or

              d-Delete a range of records that encompasses all the records:
              dim tbl as P
              tbl = table.open("........")
              query.filter =".t."
              qry = tbl.query_create()
              tbl.delete_range()
              tbl.close()

              This will work even if you have Forms/Browses based on the table open and staring you in the face!

              Take your pick! I prefer option d.

              Comment


                #8
                Re: tbl.zap() not working for me

                I prefer gathering information first and then append it to the table.
                Just before that I zap that table.

                Code:
                DIM Append as P
                tbl = table.open("your_table_name",FILE_RW_EXCLUSIVE)
                if (tbl.file_mode_get() = FILE_RW_EXCLUSIVE) then
                	tbl.zap(.T.)
                else
                	ui_msg_box("Zap Data","You do not have exclusive use of the table.",UI_STOP_SYMBOL)
                	end
                end if
                append.t_db = "tmp"
                append.m_key = ""

                For me it's easy, simple and had never troubles.
                And if it should happen I have to gather my information again in 'temp' file "tmp.dbf"

                Just as Cal stated I open a table and work with it after zapping.
                And I wonder why should I close all other tables while zapping one table.

                my 2 cents

                Good luck

                Ton Spies
                Most things are simple but unfortunately only after the first time

                Comment


                  #9
                  Re: tbl.zap() not working for me

                  report it as a bug
                  Cole Custom Programming - Terrell, Texas
                  972 524 8714
                  [email protected]

                  ____________________
                  "A young man who is not liberal has no heart, but an old man who is not conservative has no mind." GB Shaw

                  Comment


                    #10
                    Re: tbl.zap() not working for me

                    I've recently built some scripts with lots of operations in them. I found that sometimes A5 does in fact not seem to close tables when it's supposed to, and I would get errors telling me table was in use.

                    However, I found a good workaround (suggested by Ira Pelow at the user's conference).

                    Create each operation as a Separate function and then call the functions in your script. I have never had any problems with that technique, and I regularly run a script that performs almost 80 sequential operations using dozens of tables... These operations include pack's and zap's, which require exclusive access.

                    This technique also kept my master script much neater, and made trouble shooting considerably easier. Better still, if I needed to repeat an operation, I could do it with one line of code. (Thanks Ira!)

                    (It also seems to run faster... but I could be imagining that.)

                    dm
                    Last edited by Dave McCormick; 09-21-2006, 11:33 AM.

                    Comment


                      #11
                      Re: tbl.zap() not working for me

                      Thanks all,

                      This gives me a few leads to work on. One will surely emerge successful. And then as I'm using Table.enum_open() to check the table status, I discover another table won't close issue I've spent the day with. Posted separately.

                      Mike W
                      Mike W
                      __________________________
                      "I rebel in at least small things to express to the world that I have not completely surrendered"

                      Comment


                        #12
                        Re: tbl.zap() not working for me

                        Originally posted by Dave McCormick View Post
                        However, I found a good workaround (suggested by Ira Pelow at the user's conference).
                        Actually Dave, it is not a workaround, it's a better methodology.

                        And what you said is another independent validation that those who use UDF's over scripts operate more reliabily and have few problems with synchronous issues. I NEVER use XBASIC_WAIT_FOR_IDLE() and the like, and never have issues. Could it be that I use functions almost exclusively? Ya think?:)

                        Originally posted by Dave McCormick View Post
                        (It also seems to run faster... but I could be imagining that.)
                        Global Function calls (UDF's) overhead is about 15 times faster than running Script_play("scriptname"), so yes, it is faster. Of course the code itself operates at the same speed with either.
                        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


                          #13
                          Re: tbl.zap() not working for me

                          From the days of clipper: If you use more than one time for a different form, report etc., write a script.

                          Dave
                          www.lotrun.com

                          PS I don't miss clipper!
                          Dave Mason
                          [email protected]
                          Skype is dave.mason46

                          Comment

                          Working...
                          X