#129146 - 2004-11-09 05:12 AM
exit command
|
taylor
Fresh Scripter
Registered: 2004-10-21
Posts: 9
|
Dear, I saw "exit" command in many function,such as "exit 87","exit 1","exit(0)","exit 0" and so on. What difference between them? Thanks! :confused:
|
|
Top
|
|
|
|
#129148 - 2004-11-15 10:28 AM
Re: exit command
|
taylor
Fresh Scripter
Registered: 2004-10-21
Posts: 9
|
Thanks!Does anybody give me some information such as link about the exit command?
|
|
Top
|
|
|
|
#129150 - 2004-11-16 01:07 PM
Re: exit command
|
taylor
Fresh Scripter
Registered: 2004-10-21
Posts: 9
|
Thanks,but I couldn't find the detail explain for exit command,such as exit 0, exit 1,exit 87 and so on.
|
|
Top
|
|
|
|
#129152 - 2004-11-16 01:20 PM
Re: exit command
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
The number used is not special in any way. It is returned to the calling script or program, which can decide what to do depending on the number that you returned.
You might choose "1" to mean "Some sort of problem happened", "2" to mean "I cannot find the file", "5" to mean "I don't have permission to open the file" and so-on.
The only rule you should stick to is that zero means that there was no problem.
It is a good idea to try an use a number whose Windows/DOS error message has a similar meaning.
To display some of the standard error messages: Code:
Break On For $i = 0 to 9999 $=Execute("Exit "+$i) If Not InStr(@SERROR,"(317 / 13D)") @ERROR " : " @SERROR @CRLF EndIf Next
If you only ever want to determine whether an error occurred or not, you may simply stick to "0" for no error and "1" for error.
|
|
Top
|
|
|
|
#129154 - 2004-11-16 02:21 PM
Re: exit command
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
IIRC it is only the older manuals (pre-4.20) that have the error codes, and they are the English language versions.
Printing them yourself will give you the installed language version, and makes searching for something appropriate much easier.
Here is a more useful example. When prompted, supply an error number to display or a string to search for a matching error: Code:
Break ON $=SetOption("WrapAtEOL","ON") $=SetOption("ASCII","ON") "Enter an error code / string or null to exit: " GetS $s While $s If CStr(Val($s))=CStr($s) $=Execute("Exit "+$s) @ERROR " : " @SERROR @CRLF Else $iLine=0 For $iError = 0 to 9999 $=Execute("Exit "+$iError) If Not InStr(@SERROR,"(317 / 13D)") If InStr(@SERROR,$s) @ERROR " : " @SERROR @CRLF $iLine=$iLine+1 If Not ($iLine MOD 20) "Hit a key for next page or 'x' to exit search: " Get $k Chr(13) " " Chr(13) If $k="x" $iERROR=9999 EndIf EndIf EndIf EndIf Next If Not $iLine "No error strings matched." @CRLF EndIf EndIf "Enter an error code / string or null to exit: " GetS $s Loop Exit 0
|
|
Top
|
|
|
|
#129155 - 2004-11-16 02:35 PM
Re: exit command
|
Jochen
KiX Supporter
   
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
|
|
Top
|
|
|
|
#129160 - 2004-11-22 10:59 AM
Re: exit command
|
Richard H.
Administrator
   
Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
|
Quote:
try entering 'exit'
Entering exit? LOL
|
|
Top
|
|
|
|
Moderator: Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart
|
1 registered
(Allen)
and 1047 anonymous users online.
|
|
|