Page 1 of 1
Call gadget with variable?
Posted: Thu Jun 30, 2022 2:08 pm
by vwidmer
I have:
txtplgCoolBOX = TextGadget(#PB_Any, 0, 10, 100, 25, "plgCoolBOX", #PB_Text_Center)
I would like to do something like
SetGadgetText(Val("txt"+deviceName$),"CoolerBox")
this does not work..
how can I do something like this?
Thanks
Re: Call gadget with variable?
Posted: Thu Jun 30, 2022 2:23 pm
by NicTheQuick
This only works with Maps:
Code: Select all
NewMap gadgets.i()
gadgets("txtplgCoolBOX") = TextGadget(#PB_Any, 0, 10, 100, 25, "plgCoolBOX", #PB_Text_Center)
SetGadgetText(gadgets("txt" + deviceName$), "CoolerBox")
But why do you want this? Seems a bit odd to me.
Re: Call gadget with variable?
Posted: Thu Jun 30, 2022 2:35 pm
by vwidmer
Thanks I will try.
I have a few containers that have text, button
I have a function that's pulling info from multiple urls and then need to populate the info above.
So I would like to just have a loop to do that without having to call each gadget.
Maybe there is a better way to do that?
Re: Call gadget with variable?
Posted: Fri Jul 01, 2022 1:53 pm
by HeX0R
I still have no idea what you are going to do, but my proposal would be:
use Dialogs
Code: Select all
Procedure.s GetXMLString()
Protected XML$
XML$ + "<?xml version='1.0' encoding='UTF-16'?>"
XML$ + ""
XML$ + "<dialogs>"
XML$ + " <window name='win_main' flags='#PB_Window_SystemMenu' minwidth='200' xpos='407' ypos='541'>"
XML$ + " <vbox>"
XML$ + " <text name='txtplgCoolBOX' text='plgCoolBOX' flags='#PB_Text_Center'/>"
XML$ + " </vbox>"
XML$ + " </window>"
XML$ + "</dialogs><!--DDesign0R Definition: PureBasic|1|1|0||-|0-->"
ProcedureReturn XML$
EndProcedure
a$ = GetXMLString()
If ParseXML(0, a$) And XMLStatus(0) = #PB_XML_Success
CreateDialog(0)
OpenXMLDialog(0, 0, "win_main")
deviceName$ = "plgCoolBOX"
SetGadgetText(DialogGadget(0, "txt" + deviceName$), "CoolerBox")
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
Re: Call gadget with variable?
Posted: Fri Jul 01, 2022 2:21 pm
by Fred
You can also use the Runtime operator for this:
Code: Select all
Define txtplgCoolBOX
Runtime txtplgCoolBOX
OpenWindow(0, 100, 100, 600, 400, "Test")
txtplgCoolBOX = TextGadget(#PB_Any, 0, 10, 100, 25, "plgCoolBOX", #PB_Text_Center)
SetGadgetText(GetRuntimeInteger("txtplgCoolBOX"), "CoolerBox")
Repeat
event = WaitWindowEvent()
Until Event= #PB_Event_CloseWindow
Re: Call gadget with variable?
Posted: Fri Jul 01, 2022 6:27 pm
by NicTheQuick
Oh, right. I totally forget about the Runtime things.
