Topic : The GFA-Basic Compendium Author : GFA Systemtechnik GmbH Version : GFABasic.HYP v2.98 (12/31/2023) Subject : Documentation/Programming Nodes : 899 Index Size : 28056 HCP-Version : 3 Compiled on : Atari @charset : atarist @lang : @default : Document not found @help : Help @options : +g -i -s +z @width : 75 @hostname : STRNGSRV @hostname : CAB @hostname : HIGHWIRE @hostname : THING View Ref-FileAfter this dry run we will now look at an example of an accessory program. A particularly brief example: $m1000 ap_id&=APPL_INIT() IF ap_id&=0 ALERT 1,"I am not|an accessory now.",1,"Return",a& END ENDIF me_id&=MENU_REGISTER(ap_id&," Colour switch ") DO ~EVNT_MESAG(0) IF MENU(1)=40 ALERT 1,"Color switch",1,"bw|wb",a& SETCOLOR 0,a& ENDIF LOOP In the first line, the program reserves for itself 1000 bytes of storage space. Then it announces itself as a GEM application and obtains an application ID which it puts into the variable ap_id&. If ap_id& equals 0, the program was not started as an accessory. It displays a message to this effect and terminates itself. The line with MENU_REGISTER() passes the accessory's name to GEM and obtains a menu ID number me_id&. Then follows an endless loop scanning the message buffer with EVNT_MESAG(). When the accessory receives the message that it has been called (MENU(1)=40), it activates itself. In this example, however, the action is rather minimal. The accessory lets you invert the screen with SETCOLOR and then returns to its endless Loop. If more than one accessory exists, it will be necessary to determine which has been selected. MENU(5) holds the ID of the selected accessory.