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

error handling

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

    error handling

    Anyone like to tell me why this 'snippet' will not resume counting??????

    ui_msg_box("","Start",ui_ok)
    on error goto error_handler

    for x = 1 TO 10
    if (x = 3) then
    ui_msg_box("","Error",ui_ok)
    goto error_handler
    end if
    ui_msg_box("Counting",(str(x)),ui_ok)
    next x

    ui_msg_box("END","Made it to end",ui_ok)

    end

    error_handler:
    ui_msg_box("","Error processed.",ui_ok)
    resume next
    ' end

    #2
    RE: error handling

    why do I always see the answer AFTER I post it?????
    D

    Comment


      #3
      RE: error handling

      Well, it still won't work...????
      D

      Comment


        #4
        RE: error handling

        When I run this script, I get 4 error msgs on the first tbl, 3 on the second, and 2 on the third.... WHY?????
        the first two msgs do not refer to any tbl name. the first just says 'not found' the second says 'tbl not found'.
        Then 'd_customers tbl not found' and 'd_customers not found'.
        On the second tbl, 'c_schedule tbl not found' and that repeats exactly; then 'c_schedule not found'.
        On the third, 'b_main_menu tbl not found' and that repeats exactly....
        Confusing
        D


        'Date Created: 02-Oct-2004 04:36:40 AM
        'Last Updated: 02-Oct-2004 05:11:48 AM
        'Created By : Administrator
        'Updated By : Administrator


        on error goto error_handler

        dim mypointer as p
        dim tblname as c

        mypointer=d_customers
        tbl.mypointer.open()
        tblname="d_customers"
        tbl.tblname.open()

        mypointer=c_schedule
        tblname="c_schedule"
        tbl.mypointer.open()
        tbl.tblname.open()

        mypointer=b_main_menu
        tblname="b_main_menu"
        tbl.mypointer.open()
        tbl.tblname.open()

        end

        error_handler:
        err = error_code_get()
        msg = error_text_get(err)
        ui_msg_box("Error",tblname+" "+msg,ui_ok)
        resume next
        end
        'on error goto next 'goes to next line - expects an error handler
        'on error resume 'disables error handling
        'on error resume label name 'ignore error and branch to label name
        'on error resume next 'ignore error and resume next line

        Comment


          #5
          RE: error handling

          Checkout "implicit declaration" in the manual. You have not declared your variable 'x' and A5 thinks it is a character variable. The code below works.

          Regards,
          Trevor

          "Anyone like to tell me why this 'snippet' will not resume counting??????

          ui_msg_box("","Start",ui_ok)
          on error goto error_handler

          dim x as n
          for x = 1 TO 10
          if x=3
          ui_msg_box("","Error",ui_ok)
          goto error_handler
          end if
          ui_msg_box("Counting",str(x),ui_ok)
          next x
          ui_msg_box("END","Made it to end",ui_ok)
          end

          error_handler:
          ui_msg_box("","Error processed.",ui_ok)
          resume next
          ' end

          Comment


            #6
            RE: error handling

            Here you go. At the end of the second block, 'Mypointer' points to the 'd_customers' table. At the end of the third block it has been changed to point at the 'c_schedule' table.

            If you want to interact with the tables simultaneously, you need to assign them different pointers (eg mypointer2, mypointer3) so that the later blocks does not change what the mypointer variable is originally set to point to.




            dim ShortTblName as c
            dim FullTblName as c
            dim Mypointer as p

            ShortTblName = "d_customers"
            FullTblName = Table.actual_filename_get(ShortTblName)
            Mypointer = table.open(FullTblName)

            ShortTblName = "c_schedule"
            FullTblName = Table.actual_filename_get(ShortTblName)
            Mypointer = table.open(FullTblName)

            etc.

            Comment


              #7
              RE: error handling

              And.... this sequence leaves a trail of opened tables behind as new ones are opened using the same pointer. Probably cannot ever close them without a system reboot.

              -- tom

              Comment


                #8
                RE: error handling

                not a system reboot, but had to get out of A5 and restart it...
                thanx guys
                I was just playing around trying to learn how to use some of these functions...
                I will print out the thread and do some more learning

                thanx again
                D

                Comment


                  #9
                  RE: error handling

                  Just curious if you guys have a previous background in another programming language? VB?

                  You seem to be using a lot of pointers and references that don't seem necessary to me. On a very regular basis I do something like this to open a table....

                  tpc = table.open("Client")

                  Simple and straight-forward. Note that nothing is DIMed and the full table name with path is not used. (And, as Tom mentioned, I always make sure the table is explicitly closed before the script ends - or before the same pointer name is used to open another table. I seldom use the same pointer name for two tables but there's always an exception.)

                  The message with pointers like this:
                  mypointer=d_customers
                  tbl.mypointer.open()
                  tblname="d_customers"
                  tbl.tblname.open()
                  did not make any sense to me at all.

                  Please don't take offense at these comments, I'm just trying to figure out where you're coming from. I'm trying to figure out if answers should consider this a learning process or an unlearning process. I know I have a terrible time trying to read VB, C languages, etc.

                  Comment


                    #10
                    RE: error handling

                    not a system reboot, but had to get out of A5 and restart it...
                    thanx guys
                    I was just playing around trying to learn how to use some of these functions...
                    I will print out the thread and do some more learning

                    thanx again
                    D

                    Comment


                      #11
                      RE: error handling

                      you beat me back...
                      I have changed the 'corrected version' of my 'abberation' to illustrate what I had in mind...
                      I was trying to 'see' exactly what a5 would report as an error when the tables did not exist... None in the original script were actual tables. I wanted to see what the errors would be if the table were opened using a pointer and by direct name. The errors are quite different and that is what I was trying to find out...
                      Sorry to cause a mix-up

                      d

                      'Date Created: 02-Oct-2004 04:36:40 AM
                      'Last Updated: 02-Oct-2004 05:36:00 AM
                      'Created By : Administrator
                      'Updated By : Administrator


                      on error goto error_handler

                      dim ShortTblName as c
                      dim FullTblName as c
                      dim Mypointer as p

                      ShortTblName = "d_customers"
                      FullTblName = Table.actual_filename_get(ShortTblName)
                      Mypointer = table.open(FullTblName)
                      tbl.shorttblname.open()

                      ShortTblName = "c_schedule"
                      FullTblName = Table.actual_filename_get(ShortTblName)
                      Mypointer = table.open(FullTblName)
                      tbl.shorttblname.open()

                      end

                      error_handler:
                      err = error_code_get()
                      msg = error_text_get(err)
                      ui_msg_box("Error",shorttblname+" "+msg,ui_ok)
                      resume next
                      end

                      Comment


                        #12
                        RE: error handling

                        One solved, one to go..
                        I cannot get the 'snippet' to count past the error.
                        I expected that 'resume next' would allow the code to continue to count up to 10 and then display the 'end' msg box....????

                        Is it my computer????
                        Can you really get it to count to 10?????
                        D

                        Comment


                          #13
                          RE: error handling

                          I think your tbl.shorttblname.open() syntax is wrong and this is what is causing the error on that line. It isn't that it can't find the file; it's that it can't find a child object (if that's the right term) called "shorttblname" that is a child of the pointer "tbl".

                          I tried it with a table that does exist and got the same error.

                          As far as I know, there is no sytax like that for opening a table.

                          Comment


                            #14
                            RE: error handling

                            The first message was the one that got my initial interest. The answer is easy - GOTO is not the same as ON ERROR GOTO. A GOTO can't be resumed but an ON ERROR can be.

                            Change the inner IF...END IF to this and try it:
                            IF x = 3 THEN
                            ui_msg_box("", "Error", ui_ok)
                            ON ERROR GOTO error_handler
                            error_generate("This is a user generated error.")
                            END IF

                            Cal Locklin
                            www.aimsdc.net

                            Comment


                              #15
                              RE: error handling

                              Cal, as to your question, I do not have a background in some other language. You are quite correct about being able to open a table with...
                              ANYTHING = table.open("Client")
                              Use of the long table name came from the first couple of examples in the manual's explanation of table.open()
                              i.e.
                              "tbl = table.open("d:\a5\a_sports\customer.dbf")
                              tbl.fetch_first()"

                              In Richard's code, the tbl.shorttblname.open() is neither correct nor necessary. The table is already open with the line...
                              Mypointer = table.open(FullTblName)
                              I must admit, when I write this stuff myself, it does not have all the long names. So, Richard, this is an example of what my code would look like for you...


                              tbl = table.open("d_customers")
                              'You now have two things. Firstly you have a pointer called 'tbl' which points to the table 'd_customers', and secondly that table is open. To do something in the table, you now reference the table using the pointer...

                              tbl.index_primary_put("Last_name") 'order by lastname
                              tbl.fetch_first() 'go to the 1st rec
                              tbl.change_begin() 'enter change mode. Don't forget to exit change mode later with tbl.change_end()
                              'To add a rec instead of changing one, use the pair tbl.enter_begin(.T.) and tbl.enter_end(.T.)
                              'now we can change fields in that 1st rec
                              tbl.last_name = "Washington"
                              tbl.first_name = "George"
                              tbl.fetch_next() 'Go the next rec (by last_name order as we set the active index to "last_name" earlier

                              tbl.change_end(.T.) 'exit rec change mode
                              tbl.close() 'close the table in memory


                              'Now, if you want to open your 2nd table...
                              tbl = table.open("c_schedule")


                              NOTE: the above code opens one instance of 'd_customers', changes values in the first rec and then closes the table before opening the next table. If you want to open the tables simultaneously you'll need a different pointer name, so instead of using "tbl", we'll use "tbl2" for the second table...

                              tbl2 = table.open("c_schedule")
                              then all your code lines for that 2nd table begin "tbl2." instead of "tbl.".

                              Comment

                              Working...
                              X