Setting Return Code at the end of a programm

Feature requests for future versions of Hollywood can be voiced here

Setting Return Code at the end of a programm

Postby p-OS » Fri May 27, 2016 3:36 am

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
p-OS
 
Posts: 70
Joined: Tue Nov 02, 2010 12:56 am

Re: Setting Return Code at the end of a programm

Postby airsoftsoftwair » Sat May 28, 2016 5:22 pm

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

Re: Setting Return Code at the end of a programm

Postby airsoftsoftwair » Tue Sep 20, 2016 9:38 pm

Code: Select all
- New: End() accepts an optional argument now which allows you to set the program's exit status
User avatar
airsoftsoftwair
 
Posts: 2198
Joined: Fri Feb 12, 2010 3:33 pm
Location: Germany

Re: Setting Return Code at the end of a programm

Postby p-OS » Tue Sep 20, 2016 10:30 pm

Code: Select all
Print("Well done , Andreas :-D")
End(0)  -- default value...nonetheless ;)
p-OS
 
Posts: 70
Joined: Tue Nov 02, 2010 12:56 am


Return to Wishlist

Who is online

Users browsing this forum: No registered users and 1 guest

cron