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

How to test if a table is closed.

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

    How to test if a table is closed.

    Running a script that copies records from one table to another. Then it opens a form that has the copied-to table.

    The problem I am having is there is apparently no pause in for the script to wait until the actual file_add_to_db(copy_db_name) has finished and closed the table.

    As result if I try and open the form with code after the file_add_to_db(copy_db_name), it screws up the form, errors out with a cannot open and sets the form back to the first revision which will still not open or allow edits so I have to restore the form to the latest version.

    I could use WAIT_UNTIL() to pause the script but that requires a logical flag and I cannot find anything telling how to test and make sure the table has been closed and released.

    Thanks in advance.

    #2
    Re: How to test if a table is closed.

    The easiest way to control script timing is to make the time sensitive portions into functions and call them sequentially.

    There is also an inuse function but that's not the actual name. Will check and post back.
    There can be only one.

    Comment


      #3
      Re: How to test if a table is closed.

      The easiest way to control script timing is to make the time sensitive portions into functions and call them sequentially.

      There is also an inuse function but that's not the actual name. Will check and post back.

      Table.in_use() with the table name as the parameter.
      There can be only one.

      Comment


        #4
        Re: How to test if a table is closed.

        There is something else going on. I commented out everything that had to do with opening the form so that just the record copying happened.

        Then even trying to manually open the form it would be screwed up and I would have to resort to the latest version.

        So it leads me to believe that once the records are copied something is screwing up the relationship between the from and the table.

        The form displays the records in the table inside a browse object if that has anything to do with it.

        Comment


          #5
          Re: How to test if a table is closed.

          Are you opening the table and

          CLOsing the table after?

          tbl.open()
          tbl.close()??
          xbasic_wait_for_idle()??
          Dave Mason
          [email protected]
          Skype is dave.mason46

          Comment


            #6
            Re: How to test if a table is closed.

            Preston,

            the function "file_add_to_db()" does not copy records from one table to another.

            Tell us more about what's going on. Spare no details.

            Are you trying to overwrite a table using the "file_add_to_db()" function ?

            Show us the entire script, with ample comments along the way. Remember we don't know anything about your database.

            Comment


              #7
              Re: How to test if a table is closed.

              Originally posted by DaveM View Post
              Are you opening the table and

              CLOsing the table after?

              tbl.open()
              tbl.close()??
              xbasic_wait_for_idle()??
              Yes.

              Comment


                #8
                Re: How to test if a table is closed.

                Originally posted by Tom Cone Jr View Post
                Preston,

                the function "file_add_to_db()" does not copy records from one table to another.

                Tell us more about what's going on. Spare no details.

                Are you trying to overwrite a table using the "file_add_to_db()" function ?

                Show us the entire script, with ample comments along the way. Remember we don't know anything about your database.
                I took the "file_add_to_db()" out as it is not needed anyway as the target table is already in the database.

                I may just forget using a form with this as last night it totally deleted the form from the db. I was going to use the form to allow them to see what was going to be written to the .ics file and also allow them to name the file to be written.

                This is part of my export to Ical .ics file thing I posted a few days ago. The plan here was to copy the records tagged for export to a different table and then run the script to write the ics file off that table. I may just look into trying to pull the data straight from the source table using a "while .not. tpi.fetch_eof()"

                Anyway here is most of the script. The bottom part is all commented out so it would not try and open the form.
                Code:
                copy_db_name = filename_decode("[PathAlias.ADB_Path]\ics.dbf")
                
                a_tbl = table.open("schedules")
                ON ERROR GOTO ERROR2608201519532700
                DIM a5_operation_order as C
                a5_operation_order = "RECNO()"
                query.order = a5_operation_order
                DIM a5_operation_filter as C
                a5_operation_filter = "Export=.T..AND.Invoice=.T."
                query.filter = a5_operation_filter
                query.options = "I"
                query.description = "Temporary Query"
                i_indx = a_tbl.query_create()
                
                copy.set = ""
                copy.db = copy_db_name
                copy.dd = .F.
                copy.delete_o_dd = .T.
                copy.records = .T.
                copy.fields = 9
                copy.field1 = "Event_Id"
                copy.field2 = "Details"
                copy.field3 = "Tmstart"
                copy.field4 = "Tmend"
                copy.field5 = "Priority"
                copy.field6 = "Alarm"
                copy.field7 = "How"
                copy.field8 = "Equip"
                copy.field9 = "Notes"
                
                'Tell them what is about to happen.
                dim rec_count as n
                rec_count = a5_get_records_in_query("schedules",a5_operation_filter,-1,.f.)
                message_text = rec_count + " Schedule/s will be exported to "+crlf(2)+ics_file+crlf(2)+ "OK to proceed?"
                operation_result=ui_msg_box("Export Operation",message_text,UI_OK_CANCEL+ UI_FIRST_BUTTON_DEFAULT+ UI_INFORMATION_SYMBOL)
                If operation_result <> ui_ok_selected then
                	end
                end if
                dim p3 as waitdialog 'Tell them to wait.
                p3.create(3,"bounce")
                p3.set_message("Stage One")
                p3.Set_Color("red")
                a_tbl.copy()
                
                
                GOTO CONTINUE2608201519532700
                ERROR2608201519532700:
                ON ERROR GOTO 0
                ui_msg_box("Error","Error running Copy Operation"+crlf()+error_text_get())
                END
                CONTINUE2608201519532700:
                a_tbl.close()
                
                WAIT_UNTIL(Table.in_use("ics.dbf",.t.),1,1) 'Wait until ics.dbf is actually closed
                p3.close() 'Close wait message
                
                'Open a Form or Browse layout, displaying all, or selected records in the layout.
                
                'DIM Shared varP_Schedule as P
                'DIM layout_name as c 
                'layout_name = "Schedule"
                'DIM tempP as p
                ''Get pointer to existing window. In case layout_name is qualified with a dictionary name, extract up to first @. In case formname has spaces, normalize it
                'tempP=obj(":"+object_Name_normalize(word(layout_name,1,"@")))
                ''Test if pointer is valid
                'if is_object(tempP) then 
                '	'Test if pointer refers to a form or browse
                '	if tempP.class() = "form" .or. tempP.class() = "browse" then 
                '		'If so, then activate the already open window
                '		tempP.activate()
                '		
                '	else
                '		'Window is not already open, so open it
                '		varP_Schedule = :Form.view(layout_name)
                '		
                '
                '	end if
                'else 
                '	varP_Schedule = :Form.view(layout_name)
                '	
                '
                'end if
                If nothing else I have learned not to copy records to a table that is used on a form unless you want the form distroyed.

                Comment


                  #9
                  Re: How to test if a table is closed.

                  copy.delete_o_dd = .T.

                  This tells the process to delete the original data dictionaries for the new version of the table. With them go any saved layouts, etc.

                  Seems you want to change that to .F. or change to an append operation, zapping the target table first.
                  There can be only one.

                  Comment


                    #10
                    Re: How to test if a table is closed.

                    Originally posted by Stan Mathews View Post
                    copy.delete_o_dd = .T.

                    This tells the process to delete the original data dictionaries for the new version of the table. With them go any saved layouts, etc.

                    Seems you want to change that to .F. or change to an append operation, zapping the target table first.
                    I was trying to find out what that meant but could not find anything on what the "copy." things meant. I will create a form again and test it out with that change to .F.

                    Will let you know.

                    Thanks.

                    Comment


                      #11
                      Re: How to test if a table is closed.

                      http://wiki.alphasoftware.com/TBL.COPY+Method

                      http://wiki.alphasoftware.com/Alpha+Five+File+Types
                      There can be only one.

                      Comment


                        #12
                        Re: How to test if a table is closed.

                        Guess I was searching wrong which is normal for me.

                        Anyway changing "copy.delete_o_dd = .T." to "copy.delete_o_dd = .F." keeps it from destroying the form.

                        Comment

                        Working...
                        X