mIRC Home    About    Download    Register    News    Help

Print Thread
#11426 16/02/03 02:52 AM
Joined: Dec 2002
Posts: 332
C
Cheech Offline OP
Fjord artisan
OP Offline
Fjord artisan
C
Joined: Dec 2002
Posts: 332
when your running a script and you get an error msg such as *invalid format (line 6 test.ini) or * /run: unable to open and etc is that considered some kind of an event ?

#11427 16/02/03 03:03 AM
Joined: Dec 2002
Posts: 699
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 699
No, there is no event to cover script errors. It has been suggested before, but as of now there isn't one.

#11428 16/02/03 04:04 AM
Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
Using COM object, you can determine whether the Run method succeed.
Code:

alias launch {
  .comopen launch WScript.Shell
  if $comerr { return 0 }
  var %r = $com(launch,Run,3,bstr,$1-)
  .comclose launch
  return %r
}

Example: $launch(command.com), $launch($mircdir) etc... returns 1 is succeed, 0 if fails.

If you want to learn more about the Run method please refer to this page.

#11429 16/02/03 04:21 AM
Joined: Dec 2002
Posts: 332
C
Cheech Offline OP
Fjord artisan
OP Offline
Fjord artisan
C
Joined: Dec 2002
Posts: 332
ok as i am not the greatest scripter tell me if i am right so far ?
you create an alias for the run command which includes the comopen command and then if if ($comerr) {
you could rerun the program ?
now as i have really no grasp on the regex i dont undestand that tutorial entirely if you have the time and wouldnt mind could you please explain the alias xrun i lil further thx smile

also i am still running V5.91 so i dont think $launch is within that ?

Last edited by Cheech; 16/02/03 04:23 AM.
#11430 16/02/03 04:55 AM
Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
$launch and /xrun aren't included in mIRC. they are an external aliases, that use a COM object called Wscript.Shell to launch applications.

The Run method is rather flexible. it allows specifying some windows attributes (hidden, minimized, maximized...), and can also be configured to wait for the program to "return" (the script won't continue until the application is closed), which is a very useful feature.

The regex is just to make the code shorter... it's for verifying the /xrun switches (-h, -n, -m, -rN).

After using /comopen to connect to an object, $comerr is to be checked, and if it has positive value the script must stop.

The $launch code simply connects to the WScript.Shell object, checks for no errors then calls the Run method. the returned value, 0 or 1, will be placed in %r, which will be returned to the user after the COM connection is closed.


Link Copied to Clipboard