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-File** Dialog Box Example ' DIAL_SMP.GFA ' DIM r%(3) ' form1%=0 ! 0 = Dialog icon1%=1 ! ICON in tree FORM1 ch_name%=2 ! FTEXT in tree FORM1 sur%=3 ! FTEXT in tree FORM1 str%=4 ! FTEXT in tree FORM1 town%=5 ! FTEXT in tree FORM1 cancel%=6 ! BUTTON in tree FORM1 ok%=7 ! BUTTON in tree FORMl r%(1)=8 ! BUTTON in tree FORM1 r%(2)=9 ! BUTTON in tree FORM1 r%(3)=10 ! BUTTON in tree FORM1 output%=11 ! STRING in tree FORM1 ' ~RSRC_FREE() ~RSRC_LOAD("\DIALOG.RSC") ! Load Resource file ~RSRC_GADDR(0,0,tree_adr%) ! Get address of Object tree ~FORM_CENTER(tree_adr%,x%,y%,w%,h%) ! Center the coordinates, depending on the current resolution ' ' Define initial editable strings CHAR{{OB_SPEC(tree_adr%,ch_name%)}}="Sherlock" CHAR{{OB_SPEC(tree_adr%,sur%)}}="Holmes" CHAR{{OB_SPEC(tree_adr%,str%)}}="221b Baker Street" CHAR{{OB_SPEC(tree_adr%,town%)}}="London N1" ' ~OBJC_DRAW(tree_adr%,0,1,x%,y%,w%,h%) ! Draw Object tree ' REPEAT ex%=FORM_DO(tree_adr%,0) ! Clicked an object with EXIT status? ' ' Put the texts from the Edit fields into the appropriate strings ch_name$=CHAR{{OB_SPEC(tree_adr%,ch_name%)}} surname$=CHAR{{OB_SPEC(tree_adr%,sur%)}} street$=CHAR{{OB_SPEC(tree_adr%,str%)}} town$=CHAR{{OB_SPEC(tree_adr%,town%)}} ' FOR i%=1 TO 3 IF BTST(OB_STATE(tree_adr%,r%(i%)),0) ! Which radio-button was selected? radio%=r%(i%) ENDIF NEXT i% UNTIL ex%=ok% OR ex%=cancel% ' ~RSRC_FREE() ! Release reserved memory ' CLS PRINT "Ended with : ";ex% PRINT "Christian name : ";ch_name$ PRINT "Surname : ";surname$ PRINT "Street : ";street$ PRINT "Town : ";town$ PRINT "Radio : ";radio% --> The file "DIALOG.RSC" is loaded, the address of the object tree is determined and the object tree coordinates are centered. Then the function OB_SPEC() is used to define the initial editable strings: OB_SPEC() returns a pointer to a TEDINFO structure, which itself contains pointers to data pertaining to editable text (validation string, color, text, and template addresses, etc.). So the 'pointer path' to the actual information is shown overleaf: Object --> TEDINFO structure --> String OB_SPEC(tree%,ch_name%) returns a pointer to the TEDINFO structure. {OB_SPEC(tree%,ch_name%)} returns the address held at that point in TEDINFO. CHAR{{OB_SPEC(tree%,ch_name%)}} gives the string initially inserted by the Resource Construction Set, in this case: 0123456789012345678901. CHAR{{OB_SPEC(tree%,ch_name%)}}="Sherlock'" assigns this preset character string a new value (namely 'Sherlock'). This is repeated for the rest of the initial data. Then the object tree is drawn and, inside the REPEAT-UNTIL loop, the main FORM_DO() routine is called. Its returned value 'ex%' determines when the loop is exited. The (edited) strings are then put back into their respective variables, after which the object status (found by OB_STATE()) of the 'radio' buttons is examined in a FOR-NEXT loop. Specifically, Bit 0 is tested with BTST(). If it is set (=1), then the corresponding button must have been selected (only one radio button can be selected at a time), and the object number of the button is stored in radio%. Finally the memory space reserved for the Resource is released again with RSRC_FREE(). (This is important!!, since otherwise the available free memory shrinks each time the program is started, which soon causes the computer to crash.) The button which caused the exit of the REPEAT-UNTIL loop is printed (6 = Cancel, 7 = Ok), followed by the data strings as they were when FORM_DO() was done for the last time and the object number of the last-selected radio button.