Can these be strings instead of numbers?
[Edit] Please ignore this request; see Little John's post below (it can already be done).
[Solved] Set/GetGadgetData as strings
[Solved] Set/GetGadgetData as strings
Last edited by BarryG on Tue Mar 10, 2020 4:03 am, edited 2 times in total.
-
- Addict
- Posts: 4527
- Joined: Thu Jun 07, 2007 3:25 pm
- Location: Berlin, Germany
Re: Set/GetGadgetData as strings
No. Now there is greater flexibility, because SetGadgetData() can be used to store a pointer to a structure, to an allocated memory area or to anything else you want.BarryG wrote:Can these be strings instead of numbers? If I need to store numbers with it, I can just do Str(number) and Val(number$), so it makes sense to make them strings instead for greater flexibility.
Re: Set/GetGadgetData as strings
Good point, Little John!
Re: [Solved] Set/GetGadgetData as strings
For remember
Code: Select all
*pText.String = AllocateStructure(String)
*pText\s = "Hello World!"
Debug *pText\s
FreeStructure(*pText)
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
- Kwai chang caine
- Always Here
- Posts: 5357
- Joined: Sun Nov 05, 2006 11:42 pm
- Location: Lyon - France
Re: [Solved] Set/GetGadgetData as strings
I don't know that, again yesterday i needed this option thanks Little JohnLitthe John wrote:No. Now there is greater flexibility, because SetGadgetData() can be used to store a pointer to a structure, to an allocated memory area or to anything else you want.
Thanks at BarryG, for lightning this subject and MkSoft for writing his example, always usefull for me for understanding a great text explanation
Code: Select all
OpenWindow(0, x, y, 300, 200, "String en gadgetdata")
ButtonGadget(0, 10, 10, 30, 20, "Data")
*pText.String = AllocateStructure(String)
*pText\s = "Hello World!"
SetGadgetData(0, *pText)
*pText = 0
*pText = GetGadgetData(0)
Debug *pText\s
FreeStructure(*pText)
Repeat : WaitWindowEvent() :Until GetAsyncKeyState_(#VK_ESCAPE)
The happiness is a road...
Not a destination
Not a destination
Re: [Solved] Set/GetGadgetData as strings
You forget remove pointer from gadgetKwai chang caine wrote:Code: Select all
OpenWindow(0, x, y, 300, 200, "String en gadgetdata") ButtonGadget(0, 10, 10, 30, 20, "Data") *pText.String = AllocateStructure(String) *pText\s = "Hello World!" SetGadgetData(0, *pText) *pText = 0 *pText = GetGadgetData(0) Debug *pText\s FreeStructure(*pText) Repeat : WaitWindowEvent() :Until GetAsyncKeyState_(#VK_ESCAPE)
Code: Select all
*pText = GetGadgetData(0)
SetGadgetData(0, 0)
FreeStructure(*pText)
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
- Kwai chang caine
- Always Here
- Posts: 5357
- Joined: Sun Nov 05, 2006 11:42 pm
- Location: Lyon - France
Re: [Solved] Set/GetGadgetData as strings
Thanks MkSoft, i don't think to do that
The happiness is a road...
Not a destination
Not a destination
Re: [Solved] Set/GetGadgetData as strings
To avoid memory leak...
Code: Select all
Procedure FreeGadgetWithData(Gadget)
Protected *mem
If IsGadget(Gadget)
*mem = GetGadgetData(Gadget)
If *mem
FreeStructure(*mem)
EndIf
FreeGadget(Gadget)
EndIf
EndProcedure
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive