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

goto "0"; resume "0"

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

    goto "0"; resume "0"

    am trying to understand these commands - I don't understand why the following script has two 'goto o' commands

    tries=0
    on error goto no_file
    '---we now have an active error trap
    fp=file.open(�a:custtemp.txt�)
    on error goto 0
    '---Dr. Wayne says this turns off the error trap
    '---I can't grasp why you would want to turn off the error trap
    text=fp.read_line()
    end
    no_file:
    on error goto 0 'does this also turn off the no_file error trap?
    tries=tries+1
    ui_msg_box(�Disk or file error�,�Place a diskette with custtemp.txt in drive A:�)
    if tries
    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

    #2
    RE: goto

    Martin, I've assumed that the command statement ON ERROR GOTO imposes a certain amount of overhead on the script. Presumably Alpha Five stops after each line to and checks to see if an error occurred, then executes the next line, stops and checks what happened, then executes the next line, stops and checks what happened... and so on. The implication of this is that the performance of the script will slow down as long as the error trap is active.

    So, in my own work here, I turn the trap off as soon as it's no longer needed.

    Depending on what happens in the error trap module itself, I frequently will turn off further trapping there, too. In these cases my script will have two separate ON ERROR GOTO 0 statements, like the one you posted.

    My goal is to enable trapping when it's needed, but to also turn it off as soon as possible, when it's no longer needed.

    Comment


      #3
      RE: goto

      Hi Tom,

      I believe what you said is absolutely correct, and while speed is not always critical, sometimes it is.

      But let me add that those who use Action scripting (with or without Inline Xbasic commands) are trapping the errors as well. Alpha 5 puts a default error trapping (pretty lousy code from the point of returning any useful info) code in the action code. If the trapping is turned off, Alpha has some default error reporting that is better than the code embedded in the Action Scripting.

      This is why I always use Xbasic code instead of Action Scripting.

      The other reason is that if I want trapping on all the time (perhaps for testing), I use a generic error trapping routine that will display errors in a helpful way. It can log the errors to a log file or display them or place them in the trace window. This is helpful for me when I want users to report errors back to me.

      Regards,

      Ira J. Perlow
      Computer Systems Design & Associates
      [email protected]
      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


        #4
        RE: goto

        I hadn't thought of the overhead aspect - good thinking.

        But I still don't understand what it does, exactly. In Dr. Wayne's new book, he says he always uses a pair of them to avoid being caught in an endless loop.

        If "goto 0" turns off the trap - then Alpha, logically, would treat it as if it had been commented out, and from that point forward stop at the "end", and not goto "nofile".

        on error goto nofile
        tries=0
        read the "A" drive statements
        on error goto 0
        'if it reads successfully, turn off "nofile"
        'and stop at the "end" statement
        end
        nofile:
        on error goto 0 '?? to provide for an error within the trap itself??
        if tries
        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


          #5
          RE: goto

          Martin,

          perhaps the distinction is in the Resume statement.

          I do not as a matter of course 'resume' at the spot which caused the error. I noticed your use of 'resume next 0', but the ramifications of it did not sink in until just now. Your 'resume next 0' will take the program back to the point which failed, and attempt it again. In this case you probably don't want to turn off the error trap just as it's headed back to the original point that failed the first time. In your design a single ON ERROR GOTO 0 will suffice.

          In my designs, I set the trap. If an error isn't thrown, I release the trap. If an error is thrown I also release the trap, but then I send the flow of the program logic elsewhere. Often to a spot a line or two 'before' the line which failed. Sometimes to a different branch of the program altogether.

          Maybe this is what Dr. Wayne had in mind in the script you are modeling.

          -- tom

          Comment


            #6
            RE: goto

            The script is just a little snippet he was using to show how to send data to drive A. I know its probably very simple - but I am having the dickens of a time trying to undestand the use of "goto 0" - but I know its important because I've seen it used a lot in scripts. To me, since he said "on error goto 0" in the error trap itself, it would logically not trap any more attempts to put a disk in drive A, and the system would be "frozen" the next time a user tried. But since this doesn't happen - I think there is some sort of equivocation on my part with the phrase "turns off the error trap"

            I have seen "resume 0" used a lot in networking scripts -
            like
            tries=0
            on error goto cantget
            f=file.open("filename",file_rw_exclusive)
            cantget:
            if tries
            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


              #7
              RE: goto

              Martin:

              I think you're getting tied up in the idea that "On Error GoTo 0" turns off error trapping. It doesn't, it restores the script to a state where, if an error occurs, you should see a "standard" A5 error message.

              In Peter's example (and in most error trapping) his code is designed to catch one very specific error, namely the absence of a disk in the drive. This is the only error that one would anticipate in this situation and the code catches it if it occurs. If the error does not occur he restores the default trapping immediately. Otherwise a later error - say a missing index tab in a t.index_primary_put() statement - would return the error message about a missing disk in drive A which, in the circumstances, wouldn't help very much!

              So, I think it's a good practice to write error traps for problems you can anticipate and then return the trapping to A5 for those you can't. This way each "on error goto" routine is immediately followed with an on error goto 0.

              Finian
              Finian

              Comment


                #8
                RE: goto

                That was a very helpful explanation, Finian.
                Thanks,
                Peter
                Peter
                AlphaBase Solutions, LLC

                [email protected]
                https://www.alphabasesolutions.com


                Comment


                  #9
                  RE: goto

                  Hi all,

                  Dr. Wayne explains somewhere that there is another reason for the "on error goto 0" statement.

                  If you have "on error goto error_Handler" in a script the error handler has to look like

                  error_handler:
                  on error goto 0
                  etc.
                  etc.

                  because were there an error in the error handler itself the code would go into an endless loop.

                  And the more useful (and complicated) your error handler is, the more realistic it is to fear this possibility.

                  Bill
                  Bill Hanigsberg

                  Comment


                    #10
                    RE: goto

                    Thank's Finnian - now if I understand correctly, one might have more than one error handler in a script - one for one reason(errors1) and one for another reason(errors2) - and once you got past reason 1 you would say on error goto errors2
                    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


                      #11
                      RE: goto

                      Yes, that's what I do anyway!

                      Finian
                      Finian

                      Comment


                        #12
                        RE: goto

                        Another view point and a special warning:

                        First, looking at the original question: "why 2 lines with 'ON ERROR goto 0'"? The first 'ON ERROR goto 0' line is read only if there is no error. If an error occurs, the the script jumps to the label line thus bypassing the first 'ON ERROR goto 0' line and the second 'ON ERROR goto 0' is placed immediately after that line in order to reset the error trapping to use the A5 system traps.

                        WARNING:
                        Be very careful about using RESUME 0, RESUME NEXT, or RESUME label. I've found that the RESUME command often takes me to the line after the one I expect so I need to modify the script to handle this. I do this by adding a non-functional command line immediately after the label. (A blank line won't do it.)

                        EXAMPLE:
                        ON ERROR goto ErrorHandler
                        tp = table.open( "tablename" )
                        ON ERROR goto 0
                        .
                        .
                        "add'l command lines>
                        .
                        .
                        Continue_script:
                        1=1 '--- THIS DOESN'T DO ANYTHING BUT TAKES UP ONE LINE.
                        .
                        .
                        "rest of script>
                        .
                        .
                        ErrorHandler:
                        "script>
                        "script>
                        RESUME Continue_script

                        Comment


                          #13
                          RE: goto

                          thank's Cal
                          that's one of the many little idiosynchonacies that can take hours and hours to figure out
                          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

                          Working...
                          X