APPLICATION Object Updated: May 31, 2006 The Application Object (alias App) provides access to application data and user-defined Exit event and FPU error event processing. PROPERTIES (Read/Write): ~~~~~~~~~~ ~~~~~~~~~~~~~ ErrorLevel Sets integer ErrorLevel parameter and exits program. App.ErrorLevel = MyErrLevel 'set ErrorLevel and exit Gets integer "ExitProcess" code after SHELL This example shows how an IDE might use this feature: DEFINT MyCompileResult, RunItToo 'code to set RunItToo option SHELL "hot.exe MyProg -s" MyCompileResult = App.ErrorLevel 'get return code of hot.exe SELECT CASE MyCompileResult CASE 0: PRINT "Finally, no error" IF RunItToo THEN SHELL "MyProg.exe" CASE 1: PRINT "Compiled with warnings" CASE 2: PRINT "ERROR parsing source code" CASE 3: PRINT "ERROR producing object module" CASE 4: PRINT "ERROR linking object modules" END SELECT Note: App.Errorlevel will return the "ExitProcess" code from any SHELLed application program. Title Set/Get title bar text. App.Title = "HotBasic Planet" MyTitle = App.Title For GUI AppType, MyForm.Caption = "Day of HotBasic" PROPERTIES (Read Only String): ~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~ ExeName Gets application name without file extention. Path Gets application path with trailing "\"; same as PATH$ String Function. r$ = App.Path PROPERTIES (Read Only Numeric): ~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~ Debugger True if debugger present. Note: May be used to detect if your application is being debugged. IF Application.Debugger THEN Application.DebugMessage = "Restart game without debugger" END IF Handle Program module handle. MyHandle = App.Handle IcoHandle Program icon handle. MyIconHandle = App.IcoHandle METHODS Arguments & Comments ~~~~~~~ ~~~~~~~~~~~~~~~~~~~~ DebugMessage + Sends string to debugger program, if any. Application.DebugMessage = "HotBabe feels your presence" Icon Sets .ico file as resource icon. App.Icon = "filename.ico" Terminate Exits program. EVENTS Arguments & Comments ~~~~~~ ~~~~~~~~~~~~~~~~~~~~ OnExit Specifies user-defined program exit routine. Note: The .OnExit procedure is called with ctrl-C, ctrl-Break or system shutdown. After the first call to the .OnExit procedure, the second exit event proceeds with normal program exit. As shown in the commented line above, the .OnExit routine may further define another .OnExit procedure, but this may result in inability of the system to shutdown normally. However, if an application always traps Exit events with .OnExit, several mechanisms still exist to stop the program. OnFPUerror Specifies user-defined FPU exception routine. Note: FPU.error (please see FPU Object) returns 7 FPU exception bits which may be examined: invalid operation (&H1), denormalized (&H2), divide by zero (&H4), overflow (&H8), underflow (&H10), precision reduced (&H20), stack fault (&H40). Note: .OnFPUerror can be dynamically turned on and off. App.OnFPUerror = zero 'use keyword "zero" to turn off FPU error trap ########### Please see hotexit.bas in the HotTrial download for an example and tutorial on APP .OnExit coding. Please see OnFPUerr.bas in the HotThing download for an example and tutorial on APP .OnFPUerror coding. + PentHouse (registered) version Copyright 2003-2005 James J Keene PhD Original Publication: Oct 24, 2003