XWidgetSoft Forum https://www.bbs.xwidget.com/ |
|
saving and getting user defined variables https://www.bbs.xwidget.com/viewtopic.php?f=10&t=2316 |
Page 1 of 1 |
Author: | qiancang [ November 23rd, 2012, 6:41 am ] |
Post subject: | saving and getting user defined variables |
Some widgets support user defined settings, such as slider shadow style by 9yomo . We should save these user defined settings in external file and reload them when XWidget restarts or widget reloads. There are 2 ways to save user defined settings, one way is setvalue() and getvalue() functions , the other way is setinivalue() and getinivalue(). Before starting learning them, please read post managing themes. It’s helpful. What’s the difference between these 2 ways?
The knowledge of form of ini file is required. The form is shown below. Attachment: iniform.jpg [ 34.31 KiB | Viewed 12742 times ] Setvalue() & Getvalue() Code: Setvalue("keyName","keyValue"); Savevalue(); theme.xwt file is a kind of ini file indeed. Setvalue() saves variable from widget to memory and savevalue() saves variable from memory to disk. They must be used together. Code: Getvalue("keyName","defaultValue"); Getvalue() is written in the function widgetOnLoad() generally. If you write Code: var num=Getvalue("uptime",18); and there is not a keyname called "uptime" in theme.xwt, Getvalue() returns 18. Hence, num=18. Setinivalue & Getinivalue Code: Setinivalue("inifile path","section","keyName","keyValue"); "inifile path" is the full path of the ini file to which you want to save variable, such as Code: "C:\\Program Files\\XWidget\\uptime.ini" or Code: widgetpath+"uptime.ini" Please use double '\' in the path. widgetpath is a variable provided by XWidget that presents the path of the widget. Code: Getinivalue("inifile path","section","keyName","defaultValue"); Examples
|
Author: | Armando [ November 23rd, 2012, 9:50 am ] |
Post subject: | Re: saving and getting user defined variables |
We will waiting... ![]() |
Author: | meme [ April 20th, 2013, 3:00 am ] |
Post subject: | Re: saving and getting user defined variables |
Thank you qiancang for this valuable information ![]() Could you please add a description for the function SaveAsDefIni() ![]() |
Page 1 of 1 | All times are UTC - 8 hours |
Powered by phpBB® Forum Software © phpBB Group http://www.phpbb.com/ |