I want to suggest to turn SC run into an function which can return the return code of the called app
(and even the whole stdout and stderr ?)
$uccess = run(%comspec% /c myApp para1);
If ($uccess == 0){msg "all went fine"}else{break;}
error level errorlevel return code returncode
Scripting: run() as function with get return code / errorlev
Re: Scripting: run() as function with get return code / erro
+1 for error code return, also it would finally allow us to script synchronous scripts that call outside programs (i.e. it would wait for run to end instead of the script running ahead).
I would suggest that if it's desirable for run() to return its own error codes that the return value would be 'called program's return code'*1000;
Which would leave 0 as 0 and other codes you'll differentiate by length.
Edit: As for stdout/err I suppose that the function could receive two optional variables for that (if its possible for XYplorer to capture them).
I would suggest that if it's desirable for run() to return its own error codes that the return value would be 'called program's return code'*1000;
Which would leave 0 as 0 and other codes you'll differentiate by length.
Edit: As for stdout/err I suppose that the function could receive two optional variables for that (if its possible for XYplorer to capture them).
Re: Scripting: run() as function with get return code / erro
This part is already possible:Twisten wrote:+1 for error code return, also it would finally allow us to script synchronous scripts that call outside programs (i.e. it would wait for run to end instead of the script running ahead).
run command, [directory], [wait=0], [show=1]
Re: Scripting: run() as function with get return code / erro
Mmm, nope.
If you use 'wait=1' you're stuck until the program is finished, can't use XYplorer at all.
If you use 'wait=0' you run uncontrollably ahead and if you're in a loop that calls that command you might end up with multiple instances of a possibly resource demanding command.
If on the other hand run is a function and therefore the script doesn't move past it until it returns the value, your script can run without interrupting normal usage.
If you use 'wait=1' you're stuck until the program is finished, can't use XYplorer at all.
If you use 'wait=0' you run uncontrollably ahead and if you're in a loop that calls that command you might end up with multiple instances of a possibly resource demanding command.
If on the other hand run is a function and therefore the script doesn't move past it until it returns the value, your script can run without interrupting normal usage.
-
admin
- Site Admin
- Posts: 64828
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
Re: Scripting: run() as function with get return code / erro
I've looked into this some weeks ago, and did not see a good solution. I might look at it again later.
FAQ | XY News RSS | XY X
Re: Scripting: run() as function with get return code / erro
I'd love to see that as well...
Atm, I'm using this approach (rudimentary but it works for me):
http://www.xyplorer.com/xyfc/viewtopic.php?f=7&t=7490
Atm, I'm using this approach (rudimentary but it works for me):
http://www.xyplorer.com/xyfc/viewtopic.php?f=7&t=7490
One of my scripts helped you out? Please donate via Paypal
Re: Scripting: run() as function with get return code / erro
Once again find myself missing a nice clean way to capture command output in a script.admin wrote:I've looked into this some weeks ago, and did not see a good solution. I might look at it again later.
Had you seen this when you looked into it last?
http://www.vbforums.com/showthread.php? ... the-output
XYplorer Beta Club