How to exit app with a value?

BlitzMax Forums/BlitzMax Programming/How to exit app with a value?

Jake L.(Posted 2007) [#1]
Basically I want to create some small plugins (EXE's) that return an integer-value to their parent app when exiting. Should be possible with some WinAPI functions, but that'll kill cross platform.

So is there something like "End(42)" ?

Thanks
Jake


Dirk Krause(Posted 2007) [#2]
WriteStdout("42"+"~n")
should do the trick.


Jake L.(Posted 2007) [#3]
Damn, too easy ;) Thanks for the fast answer!

Works like a charm. Another problem I got is that while running the process the cursor shows an hourglass no matter if I use SetPointer in the plugin or the parent app.

EDIT: Seems like the Hourglass is magically gone when running the parentapp without IDE.


CASO(Posted 2007) [#4]
@Dirk
How does the main program receive the info?


Jake L.(Posted 2007) [#5]
local subapp:TProcess=CreateProcess ("mysub.exe")
'Wait till app terminates
while subapp.Status()   'could be while status()=0, not sure from memory
wend
'get App return
print subapp.pipe.ReadLine()


The same way you can get output of subapp while running, just read from the pipe inside the loop.

And please, don't call me Dirk ;)))