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

why won't my Fetch.next fetch the next?

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

    why won't my Fetch.next fetch the next?



    I cannot find a programming error, but the following �snippet� refuses to co-operate.

    Please tell me it is simple, just do this. . .



    'Date Created: 30-Nov-2003 10:35:26 PM
    'Last Updated: 06-Dec-2003 20:09:07 PM
    'Created By :P.o.W
    'Updated By :
    debug(1)

    '**************** start of record fetch ****

    tbl = table.open("c:\asw work in progress\fox_dept\Booking Dates .dbf")

    tbl.fetch_first()

    WHILE .NOT. tbl.fetch_EOF()

    IF booking dates->Datesfixdate then tbl.fetch_next()

    end if

    �**************** start of data entry ******



    fixdate is a global variable that contains 01/05/2004 from a different table.

    Booking dates->dates is a �calender� field (365 records) first record =01/01/2004

    I have tested this in debug, and the variable and field do contain the desired data.

    The fetch loop should tbl.fetch_next (five records) until �dates� field = fixdate variable.

    It never loops. The line:

    IF booking dates->Datesfixdate then tbl.fetch_next()

    does nothing. no other records are fetched, the date is not incremented, and subsequently data is entered into the wrong records

    If anybody can see a syntax error, or suggest a more foolproof way of doing this, I would be very pleased.

    I have spent many many hours on this xbasic section, and at last it is beginning to work, thanks also to the �forum folk�. This is probably the the last piece of the puzzle I need.

    When it finally works I intend to post it, in the hope that it may be of use to someone else as well.


    Marion



    #2
    RE: why won't my Fetch.next fetch the next?

    Unless there's a cut and paste error

    IF booking dates->Datesfixdate then tbl.fetch_next()

    end if

    should be

    IF booking dates->Datesfixdate then

    tbl.fetch_next()

    end if

    and the "then" is not really necessary.

    IF ... THEN ... ELSE

    Syntax

    IF Logical_Expression1 [ THEN ] "---"then" optional
    [ Statements1 ] "---program statements on next line
    [ ELSEIF Logical_Expression2 [ THEN ]
    [Statements2]]
    ...
    [ ELSEIF Logical_ExpressionN [ THEN ]
    [ StatementsN ]]
    [ ELSE
    [ Statements ]]
    END IF
    There can be only one.

    Comment


      #3
      RE: why won't my Fetch.next fetch the next?

      Theres also a space in the path that shouldn't be there unless it is a typo.
      tbl = table.open("c:\asw work in progress\fox_dept\Booking Dates .dbf")

      Should be:
      tbl = table.open("c:\asw work in progress\fox_dept\Booking Dates.dbf") (no space between dates and .dbf)

      Phil

      Comment


        #4
        RE: why won't my Fetch.next fetch the next?



        tbl = table.open("c:\asw work in progress\fox_dept\Booking Dates .dbf")

        tbl.fetch_first()

        WHILE .NOT. tbl.fetch_EOF()

        IF booking dates->Dates=fixdate (I changed it from

        tbl.fetch_next()

        end if


        Stan, (and Phil)

        Thanks for the replies, (been away for few days).
        I made the changes and had some success.

        Although the fields of the calender table NEVER get filled in when the application is actually running, It does work about one in ten times, when run in debug mode.

        When it fails, record one is fetched OK, but then the pointer just switches back and forth between -

        IF booking dates->Dates=fixdate

        and

        tbl.fetch_next()

        It never actually fetches the next record and "dates" does not increment. stays at 01/01/200x

        I have added a counter to close the table if it gets into a "failed fetch loop", but when I run debug again it is more likely to fail than to work, so closing the table doesn't seem to help.

        I appreciate this is getting more difficult to explain, and a little frustrating.

        I have compared the syntax to various examples in the manuals, and it all looks correct.

        Any thoughts on perhaps using some sort of "reset" to set the pointers to zero or something? I cannot figure out why it is so intermitant.

        Marion

        Comment


          #5
          RE: why won't my Fetch.next fetch the next?

          Marion,

          There's no substitute for showing the entire script. Even better, post a working model of the database for us to see.

          In the script snippet you've posted the fetch_next statement only fires if the IF condition is true. Is this what you need? How will the script ever advance through all the records once it hits a false IF condition?

          I'd consider rearranging the sequence like this:
          Code:
          - open the table
          - fetch the first
          - begin the while loop setting eof condition as terminus
          
          --- if condition 1 is true then
          ------ processing here 
          ------ processing here
          --- end if
          
          - fetch the next record
          
          - end the while loop

          This puts the fetch next statement inside the while loop where it belongs, but outside the IF block so that all records are checked for the IF condition.

          -- tom

          Comment


            #6
            RE: why won't my Fetch.next fetch the next?

            Marion,

            There's no substitute for showing the entire script. Even better, post a working model of the database for us to see.

            In the script snippet you've posted the fetch_next statement only fires if the IF condition is true. Is this what you need? How will the script ever advance through all the records once it hits a false IF condition?

            I'd consider rearranging the sequence like this:
            Code:
            - open the table
            - fetch the first
            - begin the while loop setting eof condition as terminus
            
            --- if condition 1 is true then
            ------ processing here 
            ------ processing here
            --- end if
            
            - fetch the next record
            
            - end the while loop

            This puts the fetch next statement inside the while
            loop where it belongs, but outside the IF block
            so that all records are checked for the IF condition.

            -- tom

            Comment


              #7
              RE: why won't my Fetch.next fetch the next?

              What Tom said...

              so what you probably want is something like

              tbl = table.open("c:\asw work in progress\fox_dept\Booking Dates .dbf")
              tbl.fetch_first()
              WHILE .NOT. tbl.fetch_EOF()
              IF booking dates->Dates=fixdate
              'some command here to change the booking dates->Dates
              end if
              tbl.fetch_next()
              end while
              tbl.close()

              Which leads to some other points...

              you have to put the table in change mode prior to changing any of the field values.

              IF booking dates->Dates=fixdate
              tbl.change_begin()
              'some command here to change the booking dates->Dates
              tbl.change_end(.t.)
              end if

              and while we're using pointer methods
              IF booking dates->Dates=fixdate
              should be
              IF tbl.Dates=fixdate

              And in an unrelated matter, table names should not contain spaces so

              booking dates
              should be
              booking_dates

              or similar.
              There can be only one.

              Comment


                #8
                RE: why won't my Fetch.next fetch the next?

                All taken on board with thanks,

                The whole idea is to fetch records until the correct appointment date is reached, at that stage a GOTO comes in and drops the pointer down to a tbl.change_begin() and series of CASE queries.

                The problem is that the correct date is not fetched, so the CASE is never tested, and the fields not filled.

                I will post the table, and it will explain all, (plus my somewhat basic prog skills), still, whats a little embarrasment if it leads to a solution.

                Thanks all,
                I will return.

                MDW

                Comment


                  #9
                  RE: why won't my Fetch.next fetch the next?

                  Stan, Phil, Tom,

                  Seems you have cracked it for me.

                  I ran through the layout and syntax(es) you had suggested/pointed out, and what seems to have unblocked the drain is TBL.DATES as opposed to the longhand i was using.

                  I had not come across tbl.field in the manuals. What a learning curve it can be.

                  I would have trouble telling you guys just how grateful I am. in case no other insurmountable problems crop up this year, Have the best Christmas ever, and don't worry, there will be further challenges ahead I'm sure.


                  MDW

                  Comment

                  Working...
                  X