Here is an example of a VB script file with return error and its behavior with process settings.
dim a '---- var declaration
a = Inputbox("Enter number") '----Accept value of a from keyboard
if a >= 10 then '----Check value of a
msgbox 100 '----Show 100
wscript.quit(0) '---- Error code 0 is returned (No error state)
else
if a >= 0 then '----Check value of a
msgbox a '----Show 10
wscript.quit(0) '---- Error code 0 is returned (No error state)
else
msgbox -1 '----Show -1
wscript.quit(1) '---- Error code 1 is returned (Error state)
end if '----Close if
end if '----Close if
This script takes parameters from command line and shows them one by one and terminates with error code 0 (no error). If no parameter is give, it shows messages and terminates with error code 1.
Similarly you can write a Java script as well, here is an example.
This will repeat any statement within the while loop 100 times. It will increment loop variable after each iteration.
a = 1; //----initialization of a
while ( a <= 100 ) //----check value of a, if it is <= 100
{
//----comment statement
//----write any code that you want to repeat here
i++; //----increment the loop control variable a
} //----close loop
For trapping error generated from external application, the process runner uses one environment variable called PRERRORLEVEL and PRERRORMSG. When the external process wants to return some value as exit status to process runner program, they can use this environment variable and set its value to desired exit code they want. Process Runner’s Pre-run or Post-run execution feature can trap this value and control further processing accordingly. The process runner program considers non zero value of that variable as an error state and zero as a success. Same way if someone wants to get some error message back to process runner, they can use this PRERRORMSG environment variable.
|