The statement Quit[Exit Code] terminates a program immediately. All windows are closed first and then deleted.
PUBLIC FUNCTION Calcmean(fSum AS Float, fCount AS Float) AS Float IF fCount = 0 THEN PRINT "Division by zero in the function Calcmean" QUIT ENDIF ' fCount = 0 ? RETURN (fSum / fCount ) END ' FUNCTION Calcmean(fSum AS Float, fCount AS Float) AS Float
The documentation emphasizes that the command is not very successful in connection with GUI programs. You should therefore use QUIT primarily in console applications.
As of Gambas version 3.4, you can optionally give the program to be terminated an exit code that is returned to the higher-level process. The default exit code is 0, or you can evaluate and comment on your own value for the exit code.
Especially if you want to pass on a program and another (console) program is called in it, it is not always certain whether this program is installed on the system. Without a request or appropriate error handling routines, the main program would crash with a corresponding error message. In the following case, the main program is terminated cleanly with QUIT if the (console) program Subversion is not installed:
Public Sub Form_Open() ' … If Not CheckSubversion() Then Message.Error("The SUBVERSION program is not installed. \nProgram abort.") QUIT Endif ' CheckSubversion() = True ? ' … End ' Form_Open() Private Function CheckSubversion() As Boolean Exec ["which", "svn"] Wait For Read If Process.LastValue <> 0 Then ' Wert <> 0 => The client subversion is NOT installed Return False Endif ' Process.LastValue <> 0? Return True End ' Function CheckSubversion()
Articles