Question

Is it possible to get a return value other than error level from .net exe? The exe is to be called from a script, batch or rexx.

If not, can you invoke a method in an assembly from batch or rexx and retrieve a return value?

Was it helpful?

Solution

The entry (and exit) point of any .NET executable is the main method, which has to be a Static method declared with either a void or int return type.

For this reason, you cannot directly return anything other than an int.

This int value is the error level (by convention, 0 means successful).

You can still in your program write to a "status" file that will allow you to write whatever you want and read from it.

OTHER TIPS

In C/C++ context It depends on the signature of the main() method. But it is mandatory that the return should be int. So oded's suggestion is worth a try

A possible alternate solution is to have your .net method print a string to stdout which cam be redirected to rxqueue.exe which places the output in a place where rexx can find it. Then in your rexx wrapper, wait on the return and when it arrives pull from the queue.

'external.exe | rxqueue'
line. = ''
ndx = 0
do while queued() > 0
   ndx = ndx + 1    
   parse pull line.ndx
end 
line.0 = ndx  /* this is unnecessary but is a common practice to store the 
                 stem size in leaf 0 */

/* now deal with your results */
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top