Hi All!
Can anybody help me with function errorlevel() ?
I tryed to set errorlevel in HMG programs ( errorlevel(anynumber)) , but after quiting I see error exit code == 0 ...
I need this functionality, but can't understand how to set errorlevel ( to change exit error code) before quiting HMG programs.
I have tested exit code of programs with this script ( you can save in "C:\hmg.3.4.3\SAMPLES\Applications\CONTACTOS\testexit.vbs" and try to set errorlevel(33) in "contactos project" before quiting ( before windows.release) .)
dim path, WshShell
path = "C:\hmg.3.4.3\SAMPLES\Applications\CONTACTOS\contactos.exe"
Set fso = CreateObject("Scripting.FileSystemObject")
If (fso.FileExists(path)) Then
msgBox path & " exists."
Else
msgBox path & " doesn't exist."
End If
Set WshShell = WScript.CreateObject("WScript.Shell")
Do
If fso.FileExists(path) Then
RetVal = WshShell.Run( path, 1, True)
Else
RetVal = 255
End If
Loop Until True '(RetVal = 0 )
WScript.echo "Errorlevel on return was:", RetVal
MsgBox "How to change errorlevel on HMG-programs exit?" & vbCrLf & "using errorleve(errnum) ( as in pure harbour) do not work on my tests :-("
Thanks edk for answer. Yes, I have not any problems to set errorlevel() in pure consol harbours programm and get this value by VBS script. But , if I trying to add function errorlevel() to HMG GUI project ( for example to hmg.3.4.3\SAMPLES\Applications\CONTACTOS\contactos.exe ), then I can't change returning exit code by this function and used it in my VBS script. When I told HMG programs as opposite HARBOUR programs I mean GUI specific programs with non-harbours linked librires. Sorry, I am not specialist in good definitions.
@ECHO OFF
call demo.exe
ECHO ERROLEVEL=%ERRORLEVEL%
PAUSE
IF ERRORLEVEL 3 GOTO Err3
IF ERRORLEVEL 2 GOTO Err2
IF ERRORLEVEL 1 GOTO Err1
IF ERRORLEVEL 0 GOTO Err0
GOTO END
:Err0
ECHO Run for ErrorLevel=0
GOTO END
:Err1
ECHO Run for ErrorLevel=1
GOTO END
:Err2
ECHO Run for ErrorLevel=2
GOTO END
:Err3
ECHO Run for ErrorLevel=3
GOTO END
:END
ECHO End Of Batch
PAUSE