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

while .not. tbl.fetch_eof() not working

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

    while .not. tbl.fetch_eof() not working

    I have the below code attached to a button on a form. When the button is fired, the table field "Assign_workout" (which is a field in the parent table of the set the form is based from) should be set to .t. for the filtered list of records.

    Code:
    dim tbl as p
    
    tbl = table.get("workouts") ' I have also tried table.current(1)
    tbl.fetch_first()
    
    while .not. tbl.fetch_eof()
    	 tbl.change_begin()
    	 tbl.ASSIGN_WORKOUT=.t.
    	 tbl.change_end()	 
    	 tbl.fetch_next()
    end while

    The problem is that it never stops looping. I placed a ui_msg_box() in the loop so i could cancel if I needed to and it seems it would go for ever. I hit the okay button on the message box 20 times before I canceled the action...there are only 4 records in the Workouts table!!!

    I have the same code (using table.get) on another form that is based just on the workout table. This code works fine for it.

    I know this is something simple that I am doing wrong and that it is related to the fact this form is based on a set unlike the form where this code works which is based on a single table.

    Any feedback would be appreciated.
    Thanks
    Tony

    #2
    Re: while .not. tbl.fetch_eof() not working

    According to the docs, table.get() uses an OPEN file. This could be your problem. How about trying table.open().

    Comment


      #3
      Re: while .not. tbl.fetch_eof() not working

      Doug,
      I have tried table.get and table.current because the workout table is filtered (by criteria set on the form) so only selected records get their assign_workout value set to .t..

      Am i wrong in thinking that table.open() opens a new instances of the table without the filter in place.

      Comment


        #4
        Re: while .not. tbl.fetch_eof() not working

        No you are not wrong. However, you have filtered on a set and I don't think that you can then use that filter on an individual table. Why are you not using the set that is filtered? You would still be able to update the field you want to.

        Comment


          #5
          Re: while .not. tbl.fetch_eof() not working

          Just for curiosity sake and filter aside...shouldnt the code i posted work? Why does it continue to loop?

          Comment


            #6
            Re: while .not. tbl.fetch_eof() not working

            Tony,

            You could have an index problem with your data. Try rebuilding your indexes. If that does not help then try changing the message box to show some of the data so you know which records are being processed. But to your answer yes I looks like it should work OK.

            Jeff
            Jeff Ryder

            Comment


              #7
              Re: while .not. tbl.fetch_eof() not working

              Thanks Jeff. I have rebuilt my index for all tables and it did not help.

              I changed the message box to display the current record (or workout) name as it is looping....and it stays on the first record. It just repeatedly displays it.

              I have stripped down the database to just the form in question and attached it.

              The "problem" code is on the onpush event for the "Check All" button

              Comment


                #8
                Re: while .not. tbl.fetch_eof() not working

                Your script is fine (with one minor exception):

                tbl.change_end(.t.)

                Something else is wrong.

                What is the full script?

                Comment


                  #9
                  Re: while .not. tbl.fetch_eof() not working

                  Thats the whole script. I did have tbl.change_end(.t.) at first. I will add it back.

                  Comment


                    #10
                    Re: while .not. tbl.fetch_eof() not working

                    Your combination of two one to many links to the same table with one of the links set for referential integrity is causing strange behavior.
                    There can be only one.

                    Comment


                      #11
                      Re: while .not. tbl.fetch_eof() not working

                      I removed the second one to many link from the set and am still having the problem

                      Comment


                        #12
                        Re: while .not. tbl.fetch_eof() not working

                        Falling under the bizzarre category, time to post a sample. I am off to the gym, good luck.

                        Comment


                          #13
                          Re: while .not. tbl.fetch_eof() not working

                          G,
                          I attached the db to an above post.

                          Comment


                            #14
                            Re: while .not. tbl.fetch_eof() not working

                            Tony, I'm not sure why you're having this trouble. I can see it and can only say that you're doing things differently than I would ever have attempted.

                            For the benefit of others, Tony's form is based on a set. The set spec in his example is based on three tables, but the example only includes two. However, even after dropping the missing table from the set spec the problem in the form happens as he describes. The problem occurs even if referential integrity is disabled.

                            His form contains a browse object displaying the records in the primary table. His script is trying to set a logical field value in all the records of the primary table. Instead of opening a new instance of the primary table and updating the field values in all the records his script tries to establish a pointer to the primary table and then step through the records in the instance of the table supporting the form.

                            The linked child table contains JPG images in a relatively large memo file. My suspicion is that the script is running ahead of the disk activity. Each primary table record is linked to multiple child records which are relatively large (because of the embedded images). My guess is that his script is failing because of a timing issue. Each time it fetches the next record it does not stop and wait for all the related children to be fetched, too. This must happen since the script is fetching through the instance of the table supporting his set based form. I think his trouble goes away if the script doesn't try to move so much data on each fetch of the primary table records. Or, if his script is broken down into separate UDF's which run consecutively. To my way of thinking an easier approach by far is to have the script open a new instance of the one table, update all the records, refresh the display and then end.

                            Will follow this thread to see if others have better ideas.

                            -- tom

                            Comment


                              #15
                              Re: while .not. tbl.fetch_eof() not working

                              Originally posted by reynolditpi View Post
                              G,
                              I attached the db to an above post.
                              Sorry..missed it.
                              Yeh.. nothing wrong with your script and nothing bizzare either.
                              You are under the mistaken impression that the script runs indefinitely.
                              It does not.

                              Both table.current() and table.get() point to an open file. In this case and when using it in the context of a form based on a set, it points to the composite table.

                              While you do have only 4 records in the parent table, you have close to forty (I didn't count them but that's pretty close) in the composite table and that's how many times the script will run when you expect it to run 4 times only.

                              If you use table.open() instead, all is well with the world. It runs only 4 times as expected.
                              Last edited by G Gabriel; 07-09-2008, 09:08 PM.

                              Comment

                              Working...
                              X