| View previous topic :: View next topic |
| Author |
Message |
moke Contributor

Joined: 02 Jan 2002 Posts: 162
|
Posted: Thu Aug 22, 2002 1:24 pm Post subject: @retcode() question |
|
|
I usually don't use @retcode() mostly because the documentation on it says:
"This function returns the exit code (e.g. DOS errorlevel) of the last program executed using a RUN or SHELL command with a WAIT parameter."
and I don't use the wait parameter that often for Run or Shell. While doing some testing I found that the WAIT parameter may not be required to get a proper response. Can anyone confirm this?
Thanks,
moke |
|
| Back to top |
|
 |
Tommy Admin Team
Joined: 16 Nov 2002 Posts: 746 Location: The Netherlands
|
Posted: Thu Aug 22, 2002 1:53 pm Post subject: |
|
|
How could VDS know the return code of a program that has not even been finished executing
(so that the program couldn't have generated the return code yet either)?
Can it see in the future?  |
|
| Back to top |
|
 |
moke Contributor

Joined: 02 Jan 2002 Posts: 162
|
Posted: Thu Aug 22, 2002 3:12 pm Post subject: |
|
|
Ouch! I'm not really as stupid as I look, you know (it's not possible).
I think my question pertains more to commands with a yes or no answer. Did the command execute or not? For example;
Run worksheet.xls will return @retcode(0) as long as the file exists, has a file association and the action for the association is possible, even if excel has not finished loading the file. If excel has an error while loading the file the command has still been executed correctly.
Try this; rename a tif or bitmap to .xls and use RUN to open it. Excel will launch and @retcode() will be 0 but the file will generate an excel error which has nothing to do will @ retcode(). Since @retcode deals with system level codes (?), application specific errors don't necassarily effect it. So using wait in many cases does nothing.
So in some cases you can get the benefit of using @retcode() without making your app wait till the application window in question has been closed... I think
Since I can barely spell V-D-S, nevermind use it, I thought some of the more knowledgable folks out there might be able to clarify this for me.
Thanks,
moke |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Thu Aug 22, 2002 3:51 pm Post subject: |
|
|
Hiya moke,
The DOS errorlevel (or program exit code) doesn't get
set before the program exits (hence using the VDS WAIT
parameter).
The @retcode() function returns zero as a default, whether
you've ran a program or not.
BTW, I don't think VDS is spelled with dashes either...
Cheers, Mac  _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
| Back to top |
|
 |
moke Contributor

Joined: 02 Jan 2002 Posts: 162
|
Posted: Thu Aug 22, 2002 4:45 pm Post subject: |
|
|
Hey Mac,
OK... Then does that mean I can check to see if a error occured WHILE executing a command by looking for @retcode(-1), forgetting that the program itself may have had errors processing the request?
moke |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Thu Aug 22, 2002 4:55 pm Post subject: |
|
|
Prolly not unless the program exits on the error,
and ya'd still have to use WAIT to find out.
LOL, there's a reason it's called an EXIT code. It's
set when a program exits (closes), and ONLY then.
BTW, anything other than zero is usually an error,
HOWEVER, the programmer can use any exit code
he wants.
Cheers, Mac  _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
| Back to top |
|
 |
moke Contributor

Joined: 02 Jan 2002 Posts: 162
|
Posted: Thu Aug 22, 2002 5:48 pm Post subject: |
|
|
Actually, that's exactly what i'm looking for, did an error occur that caused the program to fail upon execution or did the operation fail completely. In which case, exit code 0, after a shell statement, would mean a success anything else would be failure to complete the command I think.
Thanks,
moke |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Thu Aug 22, 2002 6:14 pm Post subject: |
|
|
You can prolly use a slightly different approach to
check for a quick error exit and still not keep your
VDS program tied up.
Instead of using WAIT as a SHELL (or RUN) parameter,
put a WAIT 5 (or whatever) after the SHELL command,
then check @retcode(). This way your VDS program
can go on about its' business after a few seconds, and
@retcode() should catch the exit code if the app aborts
in that time frame.
Cheers, Mac  _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
| Back to top |
|
 |
|