Specifically, what are each of these for and how are they used:
- 'Runtime' keyword
GetRuntimeInteger(quoted_string_literal)
IsRuntime(quoted_string_literal)
Me too.Demivec wrote:Need a brief description of the 'Runtime' library v5.20b1
Code: Select all
Runtime Procedure StringBoomBox()
GadgetID.i = DialogGadget(0,"text_gadget")
If GadgetID.i > -1
SetGadgetText(GadgetID.i,"I'm called from a runtime :)")
EndIf
EndProcedure
Runtime Procedure CheckBoxEvent()
GadgetID.i = DialogGadget(0,"string_gadget")
If GadgetID.i > -1
SetGadgetText(GadgetID.i,"Activated from "+Str(EventGadget())+" | "+Str(GadgetID.i))
EndIf
Debug "CheckBoxEvent"
EndProcedure
Procedure Main()
;sorry for this mess, needed to include the xml ;)
Protected XMLS.s = "<?xml version="+#DQUOTE$+"1.0"+#DQUOTE$+"?>"+#CRLF$+#CRLF$+
"<!-- Window -->"+#CRLF$+
"<window id="+#DQUOTE$+"0"+#DQUOTE$+" name="+#DQUOTE$+"hello"+#DQUOTE$+" text="+#DQUOTE$+"Window"+#DQUOTE$+" label="+#DQUOTE$+"TestDialog"+#DQUOTE$+" width="+#DQUOTE$+"320"+#DQUOTE$+" height="+#DQUOTE$+"10"+#DQUOTE$+" flags="+#DQUOTE$+"#PB_Window_SizeGadget|#PB_Window_MaximizeGadget|#PB_Window_MinimizeGadget"+#DQUOTE$+">"+#CRLF$+
" <splitter width="+#DQUOTE$+"300"+#DQUOTE$+" height="+#DQUOTE$+"500"+#DQUOTE$+">"+#CRLF$+
" <hbox>"+#CRLF$+
" <checkbox name="+#DQUOTE$+"checkbox1"+#DQUOTE$+" text="+#DQUOTE$+"Run only one Instance"+#DQUOTE$+" disabled="+#DQUOTE$+"yes"+#DQUOTE$+" Flags="+#DQUOTE$+""+#DQUOTE$+"/>"+#CRLF$+
" <progressbar text="+#DQUOTE$+"Vrey vreyv rye"+#DQUOTE$+"/>"+#CRLF$+
" <trackbar text="+#DQUOTE$+"Ole"+#DQUOTE$+" invisible="+#DQUOTE$+"no"+#DQUOTE$+" flags="+#DQUOTE$+"#PB_TrackBar_Ticks|#PB_TrackBar_Ticks|#PB_TrackBar_Ticks"+#DQUOTE$+" width="+#DQUOTE$+"150"+#DQUOTE$+"/>"+#CRLF$+
" <option text="+#DQUOTE$+"option 1"+#DQUOTE$+" name="+#DQUOTE$+"option1"+#DQUOTE$+" onevent="+#DQUOTE$+"CheckBoxEvent()"+#DQUOTE$+"/>"+#CRLF$+
" <option text="+#DQUOTE$+"option 2"+#DQUOTE$+"/>"+#CRLF$+
" </hbox>"+#CRLF$+
" <vbox>"+#CRLF$+
" <listview text="+#DQUOTE$+"option 3"+#DQUOTE$+" height="+#DQUOTE$+"50"+#DQUOTE$+"/>"+#CRLF$+
" <button text="+#DQUOTE$+"Click me"+#DQUOTE$+" name="+#DQUOTE$+"string"+#DQUOTE$+" onevent="+#DQUOTE$+"StringBoomBox()"+#DQUOTE$+"/>"+#CRLF$+
" <listicon text="+#DQUOTE$+"option 4"+#DQUOTE$+" height="+#DQUOTE$+"50"+#DQUOTE$+"/>"+#CRLF$+
" <string name="+#DQUOTE$+"string_gadget"+#DQUOTE$+" text="+#DQUOTE$+"string content"+#DQUOTE$+"/>"+#CRLF$+
" <editor text="+#DQUOTE$+"editorgadget"+#DQUOTE$+" height="+#DQUOTE$+"50"+#DQUOTE$+"/>"+#CRLF$+
" <text text="+#DQUOTE$+"Text gadget"+#DQUOTE$+" name="+#DQUOTE$+"text_gadget"+#DQUOTE$+"/>"+#CRLF$+
" </vbox> "+#CRLF$+
" </splitter>"+#CRLF$+
"</window>"
Debug "Opening dialog.."
Debug "Data: "+XMLS.s
If CatchXML(0, @XMLS.s,StringByteLength(XMLS.s))
;IsRuntime(Var.s) usage
If Not IsRuntime("StringBoomBox()") : Debug "StringBoomBox() --> not runtime, you will see an error.." : EndIf
If Not IsRuntime("CheckBoxEvent()") : Debug "CheckBoxEvent() --> not runtime, you will see an error.." : EndIf
If CreateDialog(0)
If Not OpenXMLDialog(0, 0, "hello")
Debug DialogError(0)
End ;- I get an IMA here, can someone confirm?
EndIf
HideWindow(0, 0)
While WaitWindowEvent() <> #PB_Event_CloseWindow : Wend
EndIf
Else
Debug "nope.."
EndIf
EndProcedure
Main()
Thank you for your explanation.Fred wrote:You can also imagine a small scripting frontend which could change the value of your variables on the run.
Code: Select all
Define d1tmp = 1, d2tmp = 4, d3tmp = 9
Runtime d1tmp, d2tmp, d3tmp ;what is the scope of these?
Define i
For i = 0 To 2
Debug GetRuntimeInteger("d" + Random(3, 1) + "tmp")
Next
Procedure test()
Protected x$, i
Debug "test_1()"
For i = 0 To 10
x$ = "d" + Random(3, 1) + "tmp"
Debug x$ + " = " + GetRuntimeInteger(x$) ;Are runtime variables always accessible, even when they are normally out of scope?
Next
EndProcedure
test()
Code: Select all
Dim var.s(2)
var(0) = "d1tmp"
var(1) = "d2tmp"
var(2) = "d3tmp"
This is actually an artifact that I neglected to remove as I modified the code while posting the message. It has been corrected. Thanks for pointing it out.fsw wrote:Why do you need this?
It's never accessed...Code: Select all
Dim var.s(2) var(0) = "d1tmp" var(1) = "d2tmp" var(2) = "d3tmp"
I used the example (http://www.purebasic.fr/english/viewtop ... 14#p415214) provided by Fred and messed around with it. It's kinda self explanatory.Demivec wrote:@Deluxe0321: thanks for your example code. It doesn't run perfectly but does expand my views a bit. How do you know what is needed in the XML to set up each of the gadgets and such?