/* ************************************************************ ** ** Created by: CodeBench 0.26 (04.01.2012) ** ** Project: ProAction ** ** File: RadioButton Example ** ** Date: 05-08-2012 23:26:12 ** ************************************************************ Example code demonstrating RadioButton Node functions and list manipulation. */ options results /* Make sure rexxsupport is available */ if ~show('L', "rexxsupport.library") then do if ~addlib("rexxsupport.library", 0, -30, 0) then do say "Cannot add rexxsupport.library!" exit 10 end end /* Make sure ProAction is available */ if ~show('P', "PROACTION") then do myCmd = "run <>NIL: *>NIL: APPDIR:ProAction" address command myCmd myCmd = "WaitForPort PROACTION" address command myCmd if RC >= 5 | ~show('P', "PROACTION") then do say "Cannot start ProAction server!" exit 10 end end address PROACTION /* Open our on arexx port for recieving GUI messages*/ myPortName = "RBN_Example" || pragma('I') if ~openport(myPortName) then do say "Cannot open own message port!" exit 10 end myGuiTags.0 = 12 myGuiTags.1.TAGNAME = "WA_Width" myGuiTags.1.TAGVALUE = 200 myGuiTags.2.TAGNAME = "WA_Height" myGuiTags.2.TAGVALUE = 50 myGuiTags.3.TAGNAME = "WA_DragBar" myGuiTags.3.TAGVALUE = 1 myGuiTags.4.TAGNAME = "WA_DepthGadget" myGuiTags.4.TAGVALUE = 1 myGuiTags.5.TAGNAME = "WA_SizeGadget" myGuiTags.5.TAGVALUE = 0 myGuiTags.6.TAGNAME = "WA_CloseGadget" myGuiTags.6.TAGVALUE = 1 myGuiTags.7.TAGNAME = "WA_Activate" myGuiTags.7.TAGVALUE = 1 myGuiTags.8.TAGNAME = "WA_Title" myGuiTags.8.TAGVALUE = "Radio Button Node Example" myGuiTags.9.TAGNAME = "WA_PubScreenName" myGuiTags.9.TAGVALUE = "Workbench" myGuiTags.10.TAGNAME = "WA_PubScreenFallBack" myGuiTags.10.TAGVALUE = 1 myGuiTags.11.TAGNAME = "WINDOW_Position" myGuiTags.11.TAGVALUE = "WPOS_CENTERSCREEN" myGuiTags.12.TAGNAME = "WINDOW_GadgetHelp" myGUITags.12.TAGVALUE = 1 myLayoutTags.0 = 3 myLayoutTags.1.TAGNAME = "LAYOUT_Orientation" myLayoutTags.1.TAGVALUE = "LAYOUT_ORIENT_VERT" myLayoutTags.2.TAGNAME = "LAYOUT_BevelStyle" myLayoutTags.2.TAGVALUE = "BVS_GROUP" myLayoutTags.3.TAGNAME = "LAYOUT_Label" myLayoutTags.3.TAGVALUE = "Radio Button Nodes" 'CREATEGUI PORTNAME "' || myPortName || '" TAGSTEM myGuiTags' if RC > 0 then do say "Cannot create GUI!" exit 10 end myGuiKey = RESULT myRadioButtonList = MakeRBNList() if myRadioButtonList ~= 0 then do /* Build our GUI */ 'ADDLAYOUT GUIID ' || myGuiKey || ' TAGSTEM ' myLayoutTags 'ADDIMAGE GUIID ' || myGuiKey || ' IMAGECLASS "label.image" TAGSTRING "LABEL_Text,Hover the mouse over the button*Nor text to display see the gadget*Nhelp text.*N*NClick the buttons and the message*Nthat ProAction sends the script will*Nbe printed to the console.,TAG_DONE"' /* Add the radio button gadget */ 'ADDGADGET GUIID ' || myGuiKey || ' GADGETCLASS "radiobutton.gadget" TAGSTRING "RADIOBUTTON_Labels,' || myRadioButtonList || ',RADIOBUTTON_Spacing,10,GA_RelVerify,1,TAG_DONE"' myRadioButtonKey = result 'OPENGUIWINDOW GUIID ' || myGuiKey do events = 1 gotMsg = waitpkt(myPortName) if gotMsg then do pkt = getpkt(myPortName) do while pkt ~= '0000 0000'x cmd = getarg(pkt) call reply(pkt) if cmd = "QUIT" then leave events parse var cmd event " GUIID" sentGuiKey . select when event = "CLOSE" then leave events when event = "GADGETUP" then do parse var cmd junk "GADGETID " gadID ' CODE ' eventCode . select when gadID = myRadioButtonKey then do say cmd end otherwise nop end end otherwise nop end pkt = getpkt(myPortName) end end end 'CLOSEGUIWINDOW GUIID ' || myGuiKey call FreeRBNList(myRadioButtonList) 'DESTROYGUI GUIID ' || myGuiKey end exit MakeRBNList: procedure expose myGuiKey rbnlist = 0 ADDRESS PROACTION /* create a list object */ /* * the exec list is stored on the GUIs object list and cleaned up for us on exit * so we only need to care about creating it. The is contants is *not* clened up * however, so we must pat attantiont disposing of the objects we place there! */ 'NEWGUIOBJECT GUIID ' || myGuiKey || ' OBJECTTYPE "GUIOBJ_List" ' if rc = 0 then do rbnlist = result /* Now we create the radiobutton nodes and add them to our list */ rbntags.0 = 3 rbntags.1.TAGNAME = "RBNA_Label" rbntags.1.TAGVALUE = "First Node" rbntags.2.TAGNAME = "RBNA_HintInfo" rbntags.2.TAGVALUE = "This is the first node!" rbntags.3.TAGNAME = "RBNA_Disabled" rbntags.3.TAGVALUE = 0 'ALLOCRADIOBUTTONNODE GUIID ' || myGuiKey || ' TAGSTEM rbntags' if rc = 0 then do rbn = result 'ADDTAIL GUIID ' || myGuiKey || ' LISTID ' || rbnlist || ' NODEID ' || rbn end rbntags.1.TAGNAME = "RBNA_Label" rbntags.1.TAGVALUE = "Second Node" rbntags.2.TAGNAME = "RBNA_HintInfo" rbntags.2.TAGVALUE = "This is the second node! It's disabled!" rbntags.3.TAGNAME = "RBNA_Disabled" rbntags.3.TAGVALUE = 1 'ALLOCRADIOBUTTONNODE GUIID ' || myGuiKey || ' TAGSTEM rbntags' if rc = 0 then do rbn = result 'ADDTAIL GUIID ' || myGuiKey || ' LISTID ' || rbnlist || ' NODEID ' || rbn end rbntags.1.TAGNAME = "RBNA_Label" rbntags.1.TAGVALUE = "Third Node" rbntags.2.TAGNAME = "RBNA_HintInfo" rbntags.2.TAGVALUE = "This is the third node! One more for luck!" rbntags.3.TAGNAME = "RBNA_Disabled" rbntags.3.TAGVALUE = 0 'ALLOCRADIOBUTTONNODE GUIID ' || myGuiKey || ' TAGSTEM rbntags' if rc = 0 then do rbn = result 'ADDTAIL GUIID ' || myGuiKey || ' LISTID ' || rbnlist || ' NODEID ' || rbn end end return rbnlist FreeRBNList: procedure expose myGuiKey parse arg rbnlist /* we remove each node and free it using the dedicated FREERADIOBUTTONNODE call */ do nodes = 1 'REMTAIL GUIID ' || myGuiKey || ' LISTID ' || rbnlist if rc ~= 0 then leave nodes rbn = result 'FREERADIOBUTTONNODE GUIID ' || myGuiKey || ' NODEID ' rbn if rc ~= 0 then say "Problem Freeing RadioButtonNode id " rbn end return