magnus
magnus

Reputation: 653

Get other than error level from exe

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?

Upvotes: 0

Views: 213

Answers (3)

Wes Miller
Wes Miller

Reputation: 2241

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 */

Upvotes: 1

Oded
Oded

Reputation: 499382

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.

Upvotes: 5

Vivek Bernard
Vivek Bernard

Reputation: 2073

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

Upvotes: 1

Related Questions