XWidgetSoft Forum
https://www.bbs.xwidget.com/

Save VARs
https://www.bbs.xwidget.com/viewtopic.php?f=10&t=2077
Page 1 of 1

Author:  Shezoid [ September 3rd, 2012, 11:14 am ]
Post subject:  Save VARs

Could you give any information about how SaveValue and SaveIni work?
I need to use vars like 'cookie' for settings ;)

Author:  Tony [ September 3rd, 2012, 4:37 pm ]
Post subject:  Re: Save VARs

you can uses setValue to save config, etc:

Code:
setValue("myconfig1","aaa");
saveIni;



and when widget Onload, you can load values,etc:

Code:
var  a = getValue("myconfig1","defaultValue");

Author:  Shezoid [ September 3rd, 2012, 9:32 pm ]
Post subject:  Re: Save VARs

Thanks! :)

Author:  Shezoid [ September 5th, 2012, 8:46 am ]
Post subject:  Re: Save VARs

what about set and get Array?
Can I save not string value?
Code:
setValue("images",imgArray);
getValue("images","defaultValue");

cause, I don't known why is not working for me.
Code:
runtime error 'imgArray[...].param' is null or not an object


or it should be like that? :(
Code:
for (var i=0;i<array.Length;i++)
{
      setValue('image'+i, array[i]);
}

for (var i=0;i<array.Length;i++)
{
     imgArray[i] = getValue('image'+i, "defaultValue");
}

Author:  qiancang [ September 6th, 2012, 12:11 am ]
Post subject:  Re: Save VARs

Shezoid wrote:
what about set and get Array?
Can I save not string value?



try it
Code:
function text1OnClick(Sender)
{
  var a=new Array(4,5);
  Setvalue("a",a)
}

function widgetOnLoad()
{
  var b = new Array(2,3);
  var c = new Array();
  c= GetValue("a",b)
}

Author:  Shezoid [ September 6th, 2012, 3:12 am ]
Post subject:  Re: Save VARs

Quote:
GetValue("a",b)

Could you explain what does second param (b) on getValue and why?

Author:  qiancang [ September 6th, 2012, 4:52 am ]
Post subject:  Re: Save VARs

Shezoid wrote:
Quote:
GetValue("a",b)

Could you explain what does second param (b) on getValue and why?


if there is not a variable "a" in the file(for example, you have not SetValue() before), you will get b , b is a default value
you can understand it at this way
Code:
if(getvalue("a")==null) c=b;
else c=getvalue("a");

Author:  Shezoid [ September 6th, 2012, 5:36 am ]
Post subject:  Re: Save VARs

Understood.

I found some bug...
Try this:
Code:
  var a=new Array(4,5);
  Setvalue("a",a);
  var b = new Array(2,3);
  var c = new Array();
  c= GetValue("a",b);
  print(c[0]);    //print:
  print(a[0]);    //print: 4
  print(c);        //print: 4,5
  print(a);        //print: 4,5

Author:  qiancang [ September 6th, 2012, 5:46 am ]
Post subject:  Re: Save VARs

i'm sorry , the getvalue() function can only get string variable
you setvalue() a Array variable , but the value is saved as string

we need a string variable to help
Code:
var a=new Array(4,5);
  Setvalue("a",a);
  var b = new Array(2,3);
  var c = new Array();
  var s;
  s= GetValue("a",b);
  c=s.split(",");

Page 1 of 1 All times are UTC - 8 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/