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

Script line Error Tracking

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

    Script line Error Tracking

    I have several automated processes that run 24/7. I do have several error handling scripts in place to handle issues I know may occur. However, there are times that Alpha will have it's own problem and I have no idea where in my script the error occurred. It takes me a lot of time, sometimes in the middle of the night, to figure out where I need to "start" the code up again to complete the script run.

    Is there anything that Alpha has that I am unaware of, or does anyone have any ideas, on how to know what line exactly a script errored out on? The error doesn't always specify and can be very vague as in: Error running Append Operation. Well I have about 20 append operations that are called in that script so which one did it fail on?

    I have thought of some different solutions but they are inefficent. For example, I thought about having a little table and I would update the line # field EVERY TIME I pass I line of code. This would slow my program down and is very ineffiecent. I also thought of just writing to a text file wtih teh line number, as this is somewhat faster. However, if the program fails, the text file doesn't get closed and I think the last few or so lines wouldn't get saved into it?? I am out of ideas and thought I better check on here before I re-invent a wheel that may already be out there

    Thank you, Nicki

    #2
    Re: Script line Error Tracking

    Hi Nicki,

    The best way to see if an operation has failed is not to run it in Silent mode.

    If all your code is in Xbasic then use Debug(1) and then you can test the values as the script progresses.

    Also, consider writing to the Trace Window.
    Regards
    Keith Hubert
    Alpha Guild Member
    London.
    KHDB Management Systems
    Skype = keith.hubert


    For your day-to-day Needs, you Need an Alpha Database!

    Comment


      #3
      Re: Script line Error Tracking

      Following other's advice I have converted operation scripts to functions like...

      Code:
      FUNCTION add_to_wss AS L ( )
      	add_to_wss = .F.
      	'This script adds any newly sold items in a week.
      	DIM Append as P
      	'open in exclusive mode if available
      	filitm = a5.Get_Path()+chr(92)+"wss.DBF"
      	itmtest = table.in_use(filitm)
      	IF itmtest
      		a_tbl = table.OPEN(a5.Get_Path()+chr(92)+"wss.DBF")
      	ELSE
      		a_tbl = table.OPEN(a5.Get_Path()+chr(92)+"wss.DBF",FILE_RW_EXCLUSIVE)
      	END IF
      	'append any new items from the temporary sales import file to the weekly sales history file
      	append.t_db = "ws01ttl"
      	append.m_key = "Upc-Store"
      	append.t_key = "F01-F1056"
      	append.m_filter = ""
      	append.t_filter = "Total_F65<>0"
      	append.type = "Unique only"
      	append.m_count = 3
      	append.m_field1 = "UPC"
      	append.m_exp1 = "@WS01TTL->F01"
      	append.m_field2 = "STORE"
      	append.m_exp2 = "@WS01TTL->F1056"
      	append.m_field3 = "DEPT"
      	append.m_exp3 = "@WS01TTL->First_F04"
      	append.t_count = 0
      	a_tbl.append()
      	a_tbl.close()
      	add_to_wss = .T.
               op_write("add_to_wss","Maintenance")
      	END FUNCTION
      The op_write() function is
      Code:
      FUNCTION op_write AS L (operation AS C, origin as C )
      	op_tbl = table.open("op_trace",FILE_RW_EXCLUSIVE)
      	op_tbl.enter_begin()
      	op_tbl.Op = operation
      	op_tbl.Date_op = time("mon dd, yyyy 0h:0m  am",now())
      	op_tbl.Origin = origin
      	op_tbl.enter_end(.t.)
      	op_tbl.close()
      	op_write = .t.
      END FUNCTION
      The op_trace table has the structure.

      Code:
      Op	Character	50	0	
      Date_Op	Character	22	0	
      Origin	Character	50	0
      So if the function add_to_wss completes I know it did and when.
      There can be only one.

      Comment


        #4
        Re: Script line Error Tracking

        Thanks, this is kind of along the same idea I had about updating a table. I guess I was hope maybe Alpha had a log file or tracer or something that kept track of what lines were processed in a script. Thanks!

        Comment


          #5
          Re: Script line Error Tracking

          There is a log/tracer function PROFILER_BEGIN() but for it to perform the corresponding PROFILER_END() must be issued. If the script fails you wouldn't get the output.
          There can be only one.

          Comment


            #6
            Re: Script line Error Tracking

            And the thing is, my code all works fine for a month and then one script will randomly fail. Once I find where it failed, I can copy from there down into a blank script, run it and move on fine so it's not a problem in my code. My issue here is trying ti find the exact line it failed so I know where to start my copy from to run.

            Comment


              #7
              Re: Script line Error Tracking

              Originally posted by NICKI004 View Post
              Thanks, this is kind of along the same idea I had about updating a table. I guess I was hope maybe Alpha had a log file or tracer or something that kept track of what lines were processed in a script. Thanks!
              Nicki, I was wondering if you got the answer to this Question? Does Alpha have a Generic Error Log that keeps track of what lines were processed in scripts that ran in one session? I.e. Error Logging functionality in .NET.

              Comment


                #8
                Re: Script line Error Tracking

                Something else you might want to do is to put "restart" labels into your code and then at the beginning, test for where to restart and just "jump" (goto) that location.

                Tom

                Comment


                  #9
                  Re: Script line Error Tracking

                  Stan's method appears to be an elegant method to log the course of successful processes. Nick I believe is looking to have the capability to identify the point of failure (or error). For very complicated scripts, I have begun to add a char variable err_trk and err_trk_scr = <current script name> and place it in the script at various lines throughout out the script where certain actions are occurring and updating the variable with err_trk = err_trk_scr + " start <Action> @ line # <line#>". Then at the start of the script I place an "on error goto error_handler" and have that value of the err_trk variable written to a tracking table, similar to what Stan wrote. It's kind of crude, but has worked very well so far to immediately identify the region of a script where failure has happened.
                  Mike W
                  __________________________
                  "I rebel in at least small things to express to the world that I have not completely surrendered"

                  Comment


                    #10
                    Re: Script line Error Tracking

                    Originally posted by Mike Wilson View Post
                    For very complicated scripts, I have begun to add a char variable err_trk ....
                    I like it!

                    Comment


                      #11
                      Re: Script line Error Tracking

                      My thought was to use

                      on error goto err_hndlr
                      PROFILER_BEGIN()

                      at the start of the script and then

                      profiler_end()
                      end
                      err_hndlr:
                      profiler_end()

                      at the end.
                      There can be only one.

                      Comment


                        #12
                        Re: Script line Error Tracking

                        I have this code in every script and UDF that I have written. In the event of an error a message box is displayed that shows error #, error text, name of the script that generated the error and the line number of the script where the error was encountered. Output of the error info can be changed to write to a log file, table, trace window, or any other place you desire.

                        If you are running an operation this will help you track down which operation tripped the error.

                        Code:
                        OPTION STRICT
                        OPTION ENCRYPTED_TOKENS
                        ON ERROR GOTO ERR_HANDLER
                        
                        
                        
                        END
                        '-----------------------------------
                        'Error handler
                        '-----------------------------------
                        ERR_HANDLER:
                        	DIM vErrN as N 
                        	DIM vMsgC as C
                        	vErrN = error_code_get()
                        
                        	vMsgC = "Error # "+ vErrN + crlf() + error_text_get(vErrN)
                        	vMsgC = vMsgC + crlf() + "Script: " + error_script_get()
                        	vMsgC = vMsgC + crlf() + "Line #: " + error_line_number_get()
                        
                        	trace.writeln(vMsgC)
                        
                        	ui_msg_box("Error", vMsgC,UI_ATTENTION_SYMBOL)
                        	vMsgC = ""
                        	
                        	END
                        Andrew

                        Comment


                          #13
                          Re: Script line Error Tracking

                          Originally posted by aschone View Post
                          I have this code in every script and UDF that I have written. In the event of an error a message box is displayed that shows error #, error text, name of the script that generated the error and the line number of the script where the error was encountered. Output of the error info can be changed to write to a log file, table, trace window, or any other place you desire.

                          If you are running an operation this will help you track down which operation tripped the error.
                          My generic error handler also uses the error_line_number_get(), etc. but I've found that the error handler doesn't get tripped by certain errors. I think that's generally errors that occur in some standard A5 "operation" (could be an official Operation saved in the Operations tab or something else - not sure) that runs "outside" of my script. In those cases, some other form of line tracking may be required.

                          Comment


                            #14
                            Re: Script line Error Tracking

                            Originally posted by CALocklin View Post
                            My generic error handler also uses the error_line_number_get(), etc. but I've found that the error handler doesn't get tripped by certain errors. I think that's generally errors that occur in some standard A5 "operation" (could be an official Operation saved in the Operations tab or something else - not sure) that runs "outside" of my script. In those cases, some other form of line tracking may be required.
                            This is true, I have found operations called via %operation%.run() or %operation%.run_silent() will not trip the error catch routine in the script. Same will happen if calling a public UDF. Due to this I will convert the operation to xbasic code as discussed by Stan in post #3. For the public UDF I will also include the same error catch routine to trap those errors.
                            Andrew

                            Comment

                            Working...
                            X