' Sample program belonging to "RSC Files in GfA Basic" ' demonstrates the DO_FORM kind of GEM ' ' Program by Robert Heessels ' Works not 100% in low or medium res! ' RESERVE 20000 ! reserves only 20k for basic, rest of memory is now free ' res%=XBIOS(4) ! get resolution IF res%=0 ! if low res the message ALERT 3,"|Please switch to|medium or high|resolution.",1,"Yes sir",but% EDIT ENDIF ' IF EXIST("resource.rsc") ! is resource file present n$="resource.rsc"+CHR$(0) ! name plus zero code at the end of the name!!! LPOKE ADDRIN,VARPTR(n$) GEMSYS 110 ! the two line to load the resource in free memory ELSE ALERT 3,"Can't find the|resource file.",1,"Arghhh",but% EDIT ENDIF ' CLS ! clears the screen ' @definities ! in these procedure are the definition names ' of the objects (merged from resource editor) DPOKE GINTIN,0 DPOKE GINTIN+2,0 GEMSYS 112 ! these line to get the resource adress in memory tree%=LPEEK(ADDROUT) ! Tree% contains the memory location of the resource ' LPOKE ADDRIN,tree% GEMSYS 54 ! form_center ! these lines changes the coordinates of the formular ' to center the formular in the resource ' POKE LPEEK(LPEEK(tree%+edit%*24+12)),0 ! this line cleares the edit line in ' the resource (labelled by Edit%) CLS IF res%=2 BOX 37,41,601,84 BOX 37,330,601,357 ! these boxes for messages to the user ELSE ALERT 1,"This test will work OK,|but it was designed in|high res, so the icons are|not quite right.",1,"So what",but% BOX 37,21,601,42 BOX 37,165,601,179 ! these boxes for messages to the user ENDIF choice1$="1" ! radio button key left group (initial) choice2$="B" ! radio button key right group (initial) PRINT AT(8,4);"Choice: ";choice1$;choice2$ PRINT AT(8,5);"Message: " ! messages to user @draw ! this procedure draws the formular to the screen ' LET exit!=FALSE ! flag indicating the exit of the formular REPEAT ! repeat until the formular must be left LPOKE ADDRIN,tree% DPOKE GINTIN,edit% ! poke here which object# is editable (-1 if none) GEMSYS 50 ! these lines activate the formular. GEM takes over ' until user choosed a touchexit of exit button LET out%=DPEEK(GINTOUT) ! Out% now contains the number of the object chosen PRINT AT(8,22);" " IF out%=ok% ! OK button chosen @pre_uit(ok%) ! Re-inverses object so it will be normal again LET exit!=TRUE ENDIF IF out%=cancel% ! Cancel button chosen @pre_uit(cancel%) ALERT 2,"Do you want to STOP|or do you want to|Continue?",1,"STOP|CONTINUE",but% IF but%=1 LET exit!=TRUE ELSE @draw ENDIF ENDIF IF out%=rect1% OR out%=rect2% ! One of the two big rectangles chosen @pre_uit(out%) PRINT AT(8,22);"No use choosing this rectangle" @draw ENDIF IF out%=icon1% ! Tree 1 chosen @pre_uit(out%) PRINT AT(8,22);"Nice tree isn't it?" @draw ENDIF IF out%=icon2% ! Tree 2 chosen @pre_uit(out%) PRINT AT(8,22);"Wow, a second tree." @draw ENDIF IF out%=icon3% ! Tree 3 chosen @pre_uit(out%) PRINT AT(8,22);"There must be a whole forrest out here!" @draw ENDIF IF out%=icon4% ! Tree 4 chosen @pre_uit(out%) PRINT AT(8,22);"Now I'm getting a bit tired." @draw ENDIF IF out%=string1% ! Title string chosen @pre_uit(out%) PRINT AT(8,22);"This is an example of a resource file used in GfA basic." @draw ENDIF IF out%=robje% ! Author string chosen @pre_uit(out%) PRINT AT(8,22);"Brought to you by Robert Heessels from STRIKE-a-LIGHT software." @draw ENDIF IF out%=radio1% ! Left radio button 1 chosen choice1$="1" ENDIF IF out%=radio2% ! 2 choice1$="2" ENDIF IF out%=radio3% ! 3 choice1$="3" ENDIF IF out%=radioa% ! Right radio button A chosen choice2$="A" ENDIF IF out%=radiob% ! B choice2$="B" ENDIF IF out%=radioc% ! C choice2$="C" ENDIF PRINT AT(8,4);"Choice: ";choice1$;choice2$ t$="" ! These 6 lines read FOR i%=0 TO 100 ! the text the user a$=CHR$(PEEK(LPEEK(LPEEK(tree%+edit%*24+12))+i%)) ! entered in T$ EXIT IF a$=CHR$(0) ! t$=t$+a$ ! NEXT i% ! PRINT AT(8,5);"Message: ";t$;" " UNTIL exit! ! end of loop: user wants to leave the formular ' GEMSYS 111 ! rsrc_free ! This frees the memory used by the resource EDIT ! THE END ' ' ========== PROCEDURE draw ! This procedure draws the formular on the screen LPOKE ADDRIN,tree% ! without activating it! DPOKE GINTIN,0 DPOKE GINTIN+2,7 DPOKE GINTIN+4,0 DPOKE GINTIN+6,0 DPOKE GINTIN+8,640 DPOKE GINTIN+10,400 GEMSYS 42 ! obj_draw RETURN ' ' ========== PROCEDURE pre_uit(a.%) ! This procedure re-inverses an object DPOKE tree%+a.%*24+10,DPEEK(tree%+a.%*24+10) AND (65535-1) RETURN ' ' ========== PROCEDURE definities ! This routines give proper names to the object ' you can make this by merging an extra file ' your resource editor makes, and make a few ' changes so GfA basic can understand it. ' (With K-Resource use the *.H file). ' /* resource set indicies for TEST */ LET form%=0 !/* form/dialog */ rect1%=1 !/* BOX in tree FORM */ radio1%=2 !/* BUTTON in tree FORM */ radio2%=3 !/* BUTTON in tree FORM */ radio3%=4 !/* BUTTON in tree FORM */ rect2%=5 !/* BOX in tree FORM */ radioa%=6 !/* BUTTON in tree FORM */ radiob%=7 !/* BUTTON in tree FORM */ radioc%=8 !/* BUTTON in tree FORM */ icon1%=9 !/* ICON in tree FORM */ icon2%=10 !/* ICON in tree FORM */ icon4%=11 !/* ICON in tree FORM */ icon3%=12 !/* ICON in tree FORM */ string1%=13 !/* BUTTON in tree FORM */ cancel%=14 !/* BUTTON in tree FORM */ ok%=15 !/* BUTTON in tree FORM */ LET edit%=16 !/* FTEXT in tree FORM */ robje%=17 !/* STRING in tree FORM */ RETURN