| View previous topic :: View next topic |
| Author |
Message |
dangt Newbie
Joined: 19 May 2009 Posts: 20
|
Posted: Thu Oct 15, 2009 10:25 pm Post subject: vds program that returns a return code |
|
|
How can I write a vds program that will return a DOS return code?
For example, when the program completes successfully it will return 0 else it will return 1. |
|
| Back to top |
|
 |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
|
| Back to top |
|
 |
vdsalchemist Admin Team

Joined: 23 Oct 2001 Posts: 1448 Location: Florida, USA
|
Posted: Fri Oct 16, 2009 11:47 pm Post subject: |
|
|
You can use the ExitProcess kernel32.dll API function.
| Code: |
:CLOSE
LoadLib kernel32.dll
%%errorlevel = 255
%R = @lib(kernel32,ExitProcess,NIL:,INT:%%errorlevel)
Exit
|
_________________ Home of
Give VDS a new purpose!
 |
|
| Back to top |
|
 |
Aslan Valued Contributor


Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Sat Oct 17, 2009 11:39 pm Post subject: |
|
|
In VDS look at @RETCODE in the helpfile.
From the helpfile
| Code: | RUN PKZIP.EXE
info Return code was @retcode()
|
Or, what about using the pipe option
| Code: | runh cmd /C set,pipe
info @pipe() |
|
|
| Back to top |
|
 |
dangt Newbie
Joined: 19 May 2009 Posts: 20
|
Posted: Mon Oct 19, 2009 3:11 pm Post subject: |
|
|
| Thanks dragonsphere! That would work. |
|
| Back to top |
|
 |
vdsalchemist Admin Team

Joined: 23 Oct 2001 Posts: 1448 Location: Florida, USA
|
Posted: Mon Oct 19, 2009 3:57 pm Post subject: |
|
|
| Aslan wrote: | In VDS look at @RETCODE in the helpfile.
From the helpfile
| Code: | RUN PKZIP.EXE
info Return code was @retcode()
|
Or, what about using the pipe option
| Code: | runh cmd /C set,pipe
info @pipe() |
|
Actually dangt was wanting a VDS program to return a errorlevel to an external program not capture an external program's errorlevel.  _________________ Home of
Give VDS a new purpose!
 |
|
| Back to top |
|
 |
Aslan Valued Contributor


Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Wed Oct 21, 2009 12:26 am Post subject: |
|
|
Thanks for the clarification
I knew I should have worn my glasses when I read dangt's post..... |
|
| Back to top |
|
 |
DaveR Valued Contributor


Joined: 03 Sep 2005 Posts: 413 Location: Australia
|
Posted: Sun Oct 25, 2009 6:04 am Post subject: |
|
|
When I run that code it closes the VDS IDE. Is this normal?
Does the ExitProcess kernel32.dll API function also close the application?
I assume that because the ExitProcess function ends a process and all its threads, and VDS only has a single thread, that calling ExitProcess will stop the application... but why does it also close the IDE. _________________ cheers
Dave |
|
| Back to top |
|
 |
vdsalchemist Admin Team

Joined: 23 Oct 2001 Posts: 1448 Location: Florida, USA
|
Posted: Mon Oct 26, 2009 12:20 pm Post subject: |
|
|
Are you running the script in the VDS IDE? If so then yes that is what it is supposed to do. When you click on the run button (green) in the VDS IDE it is VDS that is running the script not your compiled EXE which would be the red run button. When you have direct access to the executables MAIN function you could just simply give it a value to return however DLL's and other components such as ActiveX don't have direct access to the EXE's MAIN function so they (M$) invented ExitProcess for this reason. _________________ Home of
Give VDS a new purpose!
 |
|
| Back to top |
|
 |
DaveR Valued Contributor


Joined: 03 Sep 2005 Posts: 413 Location: Australia
|
Posted: Tue Oct 27, 2009 8:43 am Post subject: |
|
|
| vdsalchemist wrote: | | Are you running the script in the VDS IDE? |
Yes
| vdsalchemist wrote: | | If so then yes that is what it is supposed to do. |
Thanks _________________ cheers
Dave |
|
| Back to top |
|
 |
|