|
|
|||||||
something like : onerror("exit @error") $objConn = CreateObject("ADODB.Connection") $objConn.ConnectionTimeout = $ConnTimeout $objConn.Open($ConnDSN) endonerror instead of $objConn = CreateObject("ADODB.Connection") if @ERROR exit @ERROR endif $objConn.ConnectionTimeout = $ConnTimeout if @ERROR exit @ERROR endif $objConn.CommandTimeout = $CmdTimeout if @ERROR exit @ERROR endif $objConn.Open($ConnDSN) if @ERROR exit @ERROR endif [ 10 May 2002, 20:06: Message edited by: Radimus ] |
||||||||
|
|
|||||||
Dear Radimus, A good idea. In some other languages we have such capability. It will reduce the requirement of additional code for abnormal situations. Specially when scripts aborts. Our suggestion is to extend your OnError function with the capability to execute a piece of kixtart script f.e.
|
||||||||
|
|
|||||||
that is exactly what I meant... |
||||||||
|
|
|||||||
This came up a little while ago... Here it is: On Error handler? |
||||||||
|
|
|||||||
I need it too! |
||||||||
|
|
|||||||
I still must wonder, what for one would like this? a way to check if his script crashes? thus, lack of proper coding? |
||||||||
|
|
|||||||
Because you might want to trap certain errors that can happen within a block of code due to circumstances out of control of the script itself. Just take a look at Radimus' example. Instead of checking the error code of each COM-function, you can group them together and achive a lower KiXgolf score. |
||||||||
|
|
|||||||
I know what you mean but if you look at the code rad provided, you see this: $objConn = CreateObject("ADODB.Connection") you may get error if system does not have this functionality. and: $objConn.ConnectionTimeout = $ConnTimeout $objConn.Open($ConnDSN) these are dependant of the first one. if you don't know if the system has services of the needed type, you just want kixtart to take the errors for you? it's just sloppy code, nothing else. there is no reason why any soft or com call would return any error if not specifically needed. and needs are of 2 types: -1 = coder writes code that is unsupported -2 = end user makes a choise that causes error these are both predictable. thus, I don't see any reason for on-error "event" |
||||||||
|
|
|||||||
I have tried to write a Kix-Script to check websites in our Intranet and at the internet. For this I'm using the "WinHttp.WinHttpRequest.5.1"-object. There I can set the proxy and first of all a timeout. But when I check the websites and a timeout occurs, the Kixtart-Script Quits. In vbscript I can change this behaviour and check the error-object after the check times out. For using all of the nice COM-Objects it absolutely neccesary that we have a thing like ON ERROR RESUME NEXT. For the webcheck-script I had to change to vbscript |
||||||||
|
|
|||||||
again, your script quits because you don't have a check for the objects results. little better code will remove the need for this. also, you don't neccessarely need the winhhtp-object as with ie5 and later you can use xmlhttp-object which ships with ie (although it uses the same settings as ie). |
||||||||
|
|
|||||||
Here is a little sample code:The Script dies after the .Send when it times out. How can this be catched with kix?BREAK ON |
||||||||
|
|
|||||||
dunno why it does that for you as it does not do that for me. but what it does is give error 9 of the status line. com objects have 2 most usual errors: 6 and 9. they mostlikely mean: "this da thing is not supported" but indeed, it does not crash for me, it just returns nothing |
||||||||
|
|
|||||||
Maybe it's a Kix-Bug. |
||||||||
|
|
|||||||
it's good to quess so. I think it's bug in your OS. you have no lead what so ever what the problem is. and like your example has shown, onerror is not needed but more proper script control. basically com already is higher level scripting so it also requires more carefull coding. |