lnx2050 Posted March 4, 2004 Share Posted March 4, 2004 is here is a way to suppress automaticaly the MsgBox when a error is detected on executing script ? instead of msgbox, the script execution will abort Ln. Link to comment Share on other sites More sharing options...
Developers Jos Posted March 4, 2004 Developers Share Posted March 4, 2004 Which MessageBox or specific Error do you refer to ? Most errors can be avoided like for Run/Runwait you can specify : Opt("RunErrorsFatal", 0) SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
lnx2050 Posted March 4, 2004 Author Share Posted March 4, 2004 (edited) in fact, i try to execute $COMMANDLINE witch is sended in a command line parametermy application 's name : suclient.exe2 exemples of parameters: - Suclient audit.cmd - Suclient "Dir c:\"in case of lanching a Batch file, there's no problembut in case of Suclient "dir.cmd", the command is failed because the good correct command line must be : Suclient " cmd /C dir c:\"i looking for how to detect that the parameter is betwin " " ?; a part of my code $COMMANDLINE = $CmdLine[1] RunWait ($COMMANDLINE) Edited March 4, 2004 by lnx2050 Link to comment Share on other sites More sharing options...
Developers Jos Posted March 4, 2004 Developers Share Posted March 4, 2004 (edited) This is how you can avoid errors with your code: Opt("RunErrorsFatal", 0); no run errors ; if one parameter is specified then run the program If $CmdLine[0] = 1 then ; put " around the first parameter to be able to handle long file names Run( '"' & $CmdLine[1] & '"') if @error then ; error running the program code endif else ; no parameter specified code endif EDIT You can also take all parameters, in otther words .. not worry about the " on the command line and just add the whole thing together: Opt("RunErrorsFatal", 0); no run errors ; if one parameter is specified then run the program If $CmdLine[0] > 0 then $command= "" for $x = 1 to $CmdLine[0] $command= $command & " " $CmdLine[$x] Next ; put " around the first parameter to be able to handle long file names Run( '"' & $command & '"') if @error then ; error running the program code endif else ; no parameter specified code endif Edited March 4, 2004 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
scriptkitty Posted March 4, 2004 Share Posted March 4, 2004 Many errors can be fixed by better coding. example: ;bad code $VAR = $CmdLine[1] Msgbox(4096, "Hello ",$VAR) if you wanted to exit on error better code would be: if $CmdLine[0] < 1 then exit $VAR = $CmdLine[1] Msgbox(4096, "Hello ",$VAR) or If ubound ($CmdLine)=1 Then exit $VAR = $CmdLine[1] MsgBox(4096, "Hello ",$VAR) you can also use: IsArray IsDeclared IsFloat IsInt IsNumber IsString and MustDeclareVars might come in handy for ya RunErrorsFatal is not a substitute for thoughtful coding. ex. Opt("RunErrorsFatal", 0) $VAR = $CmdLine[1] Msgbox(4096, "Hello ",$VAR) RunErrorsFatal(0)....Sets if the script should terminate with a fatal error if a Run/RunWait function fails due to bad paths/file not found/Bad login IDs: AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
lnx2050 Posted March 4, 2004 Author Share Posted March 4, 2004 yes, but my problem is to detect the "" in the parameter. The $Cmdline[1] is saving the parameter within the "" if i send in dos prompt : Suclient "dir c:\" the $Cmdline[1] is dir c:\ but not "dir c:\" so how to detect the "" ? that's all my pbm Ln. Link to comment Share on other sites More sharing options...
Developers Jos Posted March 4, 2004 Developers Share Posted March 4, 2004 (edited) check my EDIT in the previous post.... that should take care of that issue... (i think ) Edited March 4, 2004 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now