Setting Return Code at the end of a programm

Feature requests for future versions of Hollywood can be voiced here
Post Reply
p-OS
Posts: 167
Joined: Mon Nov 01, 2010 11:56 pm

Setting Return Code at the end of a programm

Post by p-OS »

It seems it is currently not possible top set the (shell) return code of a compiled program when it quits.

If your program is meant to be called from a Shell with some self defined parameters, then it would be useful to set return code if it couldn't act as exspected, e.g. if it is called within a Shell script / Batch file...

One could define a new env variable and after program execution check the value of this env variable. But it would be more clean to use an OS' default mechanism.

I tried to set my OS' default result variable:

MorphOS:

Code: Select all

SetEnv("RC",30)
End
Besides the fact that the variable name has to be different depending on the OS running, it didn't work at all.
When a compiled Hollywood program exits, it always overrides the return code with value 0.

Imagine, your program gets an argument -textfile and shall do some operations on this file, this file might not be available -> thus porgram should quit with an error code

Code: Select all

If myaction_result="success"
  End  ; or End(0)
Else
  End(30)
EndIf
User avatar
airsoftsoftwair
Posts: 5443
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Setting Return Code at the end of a programm

Post by airsoftsoftwair »

Yes, this sounds like a useful extension. I'll try to implement this in a future version.
User avatar
airsoftsoftwair
Posts: 5443
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Setting Return Code at the end of a programm

Post by airsoftsoftwair »

Code: Select all

- New: End() accepts an optional argument now which allows you to set the program's exit status
p-OS
Posts: 167
Joined: Mon Nov 01, 2010 11:56 pm

Re: Setting Return Code at the end of a programm

Post by p-OS »

Code: Select all

Print("Well done , Andreas :-D")
End(0)  -- default value...nonetheless ;)
Post Reply