Please help a beginner.
How can I update the display after assigning a new value to the caption variable defined in Formdesigner?
Is there some kind of "refresh" procedure?
Harry
Stringgadget: Caption is a variable?
Re: Stringgadget: Caption is a variable?
Hello HarryT. If you were to assign, for example, the text string "Hello" to the caption field of a StringGadget(), it should be reflected immediately within the Form Designer window itself.HarryT wrote:How can I update the display after assigning a new value to the caption variable defined in Formdesigner?
However, if the <Caption is a variable?> option is selected, typing the word "Hello" in the caption field would only assign a string variable named "Hello" to that StringGadget(). This string variable "Hello" must then be programmatically assigned some text value to be displayed in the StringGadget(), like this:
Code: Select all
Hello.s = "Some text for the caption"Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel 
Re: Stringgadget: Caption is a variable?
Thanks for your answer. I know this, but if i assign a value to the variable, it will not update the stringgadget. What must i do to update the display?TI-994A wrote: This string variable "Hello" must then be programmatically assigned some text value to be displayed in the StringGadget(), like this:Code: Select all
Hello.s = "Some text for the caption"
I know that setgadgettext(..,..) will show the text immediatly. but i want to use the variable.
And another question: can I use a Array element like Mytext(3) as a caption variable ?
Re: Stringgadget: Caption is a variable?
Hello again HarryT. As far as I know, if variables are used, there's no way to assign or display their values within the Form Designer environment, because only code for layout and events are allowed. Accordingly, you would not be able to add the SetGadgetText() function to the form code; such additions can only be made from an external .pb source file, or if the .pbf form file is opened as a .pb or .pbi source file (not recommended).HarryT wrote:I know this, but if i assign a value to the variable, it will not update the stringgadget. What must i do to update the display?
I know that setgadgettext(..,..) will show the text immediatly. but i want to use the variable.
And another question: can I use a Array element like Mytext(3) as a caption variable ?
In any case, it is not strictly necessary to initialise the StringGadget() with any caption values or variables, as the Form Designer assigns them null values which can be re-assigned later, something like this:
(in these examples, myForm.pbf is a default form generated by Form Designer, with a single, uninitialised StringGadget() added):
Code: Select all
IncludeFile "myForm.pbf"
OpenWindow_0()
SetWindowTitle(Window_0, "My Added Title")
SetGadgetText(String_0, "My Added Caption")
While Window_0_Events(WaitWindowEvent()) : WendCode: Select all
IncludeFile "myForm.pbf"
Dim MyText.s(2)
MyText(1) = "My Added Title"
MyText(2) = "My Added Caption"
OpenWindow_0()
SetWindowTitle(Window_0, MyText(1))
SetGadgetText(String_0, MyText(2))
While Window_0_Events(WaitWindowEvent()) : WendTexas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel 
Re: Stringgadget: Caption is a variable?
Thanks again for your help. I am sorry, that i couldn't make clear what i want.
But English is not my native language.
in the form Definition i have something like this:
In my main program i want to have something like:
Of course, I can use
but with this I can use any other variable too, and any string constant.
I want to display the variable defined in the gadget definition (Mytext) WITHOUT using setgadgettext().
If this does not work, what sense makes it to have a variable as the caption?
Thanks again for your answer.
Harry
But English is not my native language.
in the form Definition i have something like this:
Code: Select all
Global Window_0
Global Text_0
Procedure OpenWindow_0(x = 0, y = 0, width = 600, height = 400)
Window_0 = OpenWindow(#PB_Any, x, y, width, height, Wincap, #PB_Window_SystemMenu)
Text_0 = TextGadget(#PB_Any, 80, 60, 110, 30, Mytext, #PB_Text_Border)
EndProcedure
Code: Select all
Mytext = "This is the text to be displayed in Textgadget Text_0"
Code: Select all
SetgadgetText(Text_0, MyText)I want to display the variable defined in the gadget definition (Mytext) WITHOUT using setgadgettext().
If this does not work, what sense makes it to have a variable as the caption?
Thanks again for your answer.
Harry
Re: Stringgadget: Caption is a variable?
If I think I understand what you mean :
You want to set up a text gadget with the text string mytext, then change the contents of mytext and you expect the textgadget to update?
If that is the case, then you cannot do that - the text gadget doesn't care what you feed into the text area as long as it's a string, it doesn't remember where you fed the string from either, just a copy of the string is sent . You will need to do a setgadgettext to tell the gadget to change the text, unless you go the WinAPI route which will be much more complex.
You want to set up a text gadget with the text string mytext, then change the contents of mytext and you expect the textgadget to update?
If that is the case, then you cannot do that - the text gadget doesn't care what you feed into the text area as long as it's a string, it doesn't remember where you fed the string from either, just a copy of the string is sent . You will need to do a setgadgettext to tell the gadget to change the text, unless you go the WinAPI route which will be much more complex.
----
R Tape loading error, 0:1
R Tape loading error, 0:1
Re: Stringgadget: Caption is a variable?
Hello HarryT. That's absolutely possible, but only for the initial values; any subsequent changes to the caption variables Mytext or Wincap require calls to the SetGadgetText() and SetWindowTitle() functions to update them accordingly. Here are the modified examples to do this:HarryT wrote:...I want to display the variable defined in the gadget definition (Mytext) WITHOUT using setgadgettext()...
(myForm.pbf: the form code as per your example)
Code: Select all
Global Window_0
Global Text_0
Procedure OpenWindow_0(x = 0, y = 0, width = 600, height = 400)
Window_0 = OpenWindow(#PB_Any, x, y, width, height, Wincap, #PB_Window_SystemMenu)
Text_0 = TextGadget(#PB_Any, 80, 60, 110, 30, Mytext, #PB_Text_Border)
EndProcedureCode: Select all
Global Wincap.s = "Variable Title"
Global Mytext.s = "Variable Caption"
IncludeFile "myForm.pbf"
OpenWindow_0()
While WaitWindowEvent() ! #PB_Event_CloseWindow : WendTexas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel 


