ban2/png

tutor/gif
Home

cell/gif

Ceasing program execution

AppBasic applications cease execution when the variable FINISHED is set to TRUE

cell/gif
1/gif Amend MinApp
Give MinApp a !RunImage directory and amend the resfile so that selecting the Quit entry in the iconbar menu generates the default event.
quit/gifOpen the edit dbox for IbarMenu's Quit menu-entry and set the Click action
2/gif Insert a ‘Menu Event’ handler in !RunImage
event/gif
DEF PROCDealWith_Menu(event,object,component)
CASE event OF
  WHEN Menu_AboutToBeShown
  WHEN Menu_HasBeenHidden
  WHEN Menu_SubMenu
  WHEN Menu_Selection
ENDCASE
ENDPROC
A Basic file containing a skeleton menu event-handler can be added to !RunImage via the application processing menu (Ctrl double-click the application).

When an event occurs in a menu object this procedure is called. The argument event indicates which type of event has taken place and object and component indicate in what object and component (if any).

3/gif Edit the event-handler
DEF PROCDealWith_Menu(event,object,component)
CASE event OF
  WHEN Menu_AboutToBeShown
  WHEN Menu_HasBeenHidden
  WHEN Menu_SubMenu
  WHEN Menu_Selection
   IF FNUtils_Object(object)="IbarMenu" AND component=1 THEN
    FINISHED=TRUE
    ENDIF
ENDCASE
ENDPROC

The function FNUtils_Object(object) is an AppBasic utility which returns the name of the resfile template used in the contruction of the object. Each menu entry is assigned a component value (unique within the object) in its resfile design

comp/gif

N.B. It doesn't matter if you leave 'empty' WHEN statements in your event-handler definitions - they will be removed when the application is compressed.
4/gif Compress the application
Compression will remove any unused variables and procedure definitions.
5/gif Worked solution