How to return exit code from Application

BlitzMax Forums/BlitzMax Beginners Area/How to return exit code from Application

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

You could also use an exception to perform an immediate exit. Something like this (untested) :-

Type MyFatalException
	Field errorCode
EndType

Try
	' main program stuff goes here
	' if there's an error throw an exception with the return code in it like so :-
	'
	If someErrorOccurred 
	 	except:MyFatalException = New MyFatalException
		except.errorCode = 2
		Throw except
	EndIf
	 
Catch e:MyFatalException
  	Return e.errorCode
End Try

' We got to the end safely
Return 0