Page 1 of 1 1
Topic Options
#122875 - 2004-07-14 01:09 PM Handling errors errorlevel & @error questions
KentLarsson Offline
Getting the hang of it

Registered: 2004-07-08
Posts: 50
Loc: Sweden, Avesta
Hi!

Can i check errorlevel in some way after a SHELL call?

And, can i set @ERROR myself in a function? If i create an UDF for example.
_________________________
Best regards, Kent

Top
#122876 - 2004-07-14 01:40 PM Re: Handling errors errorlevel & @error questions
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Quote:

Can i check errorlevel in some way after a SHELL call?




Yes, @ERROR is set to the exit value of the program called.

Quote:

And, can i set @ERROR myself in a function? If i create an UDF for example.




Yes. You will see that most UDFs exit by using "Exit n", when "n" is the value to set @ERROR to.

For example:
Code:
Function myUDF()
Exit 3
EndFunction



This will leave @ERROR set to 3. You should always set @ERROR when leaving a UDF, use "Exit 0" for success.

You can also set @ERROR in-line by using exit. To clear an error status:

$=Execute("Exit 0")

Top
#122877 - 2004-07-14 02:31 PM Re: Handling errors errorlevel & @error questions
KentLarsson Offline
Getting the hang of it

Registered: 2004-07-08
Posts: 50
Loc: Sweden, Avesta
Big thanks! Very informative answer!
_________________________
Best regards, Kent

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 640 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.087 seconds in which 0.06 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org