XWidgetSoft Forum https://www.bbs.xwidget.com/ |
|
${LifeTime} Seems to not work https://www.bbs.xwidget.com/viewtopic.php?f=3&t=3875 |
Page 1 of 1 |
Author: | Armando [ December 9th, 2013, 11:41 am ] |
Post subject: | ${LifeTime} Seems to not work |
I could not run the remaining battery time ( ${LifeTime} )... Any idea why this happens? Thanks! |
Author: | hamid [ December 10th, 2013, 9:15 am ] |
Post subject: | Re: ${LifeTime} Seems to not work |
i don't have battery to test it, but i think you could use "%LifeTime" instead when i use "${LifeTime}" i don't get anything but when i use "%LifeTime" i will get 00:00 as i said i don't have battery to be sure maybe it doesn't converted to new format yet or there is a problem with new formatting |
Author: | Armando [ December 11th, 2013, 6:28 am ] |
Post subject: | Re: ${LifeTime} Seems to not work |
Thanks Hamid!! Its works!!!!! |
Author: | Armando [ December 17th, 2013, 5:49 am ] |
Post subject: | Re: ${LifeTime} Seems to not work |
When XWidget restarts, %LifeTime change to ${LifeTime} But seems it's work anyway. It's a bit slow to change... but... works. Unfortunately: 1) shows the minutes not divided in hours (eg.: 157 minutes) ... (do not know how you become with code to hours and minutes ...). 2) when the power cord is plugged in (and the battery is charging) does not show the minutes of charging (shows 00:00) Tony: batterycore should improve! thanks! |
Author: | hamid [ December 20th, 2013, 8:37 am ] |
Post subject: | Re: ${LifeTime} Seems to not work |
Armando wrote: When XWidget restarts, %LifeTime change to ${LifeTime} But seems it's work anyway. It's a bit slow to change... but... works. try %LifeTime in code maybe it works faster; and maybe it doesn't change to ${LifeTime} in code; to set a core tag for the object in the code use this: text1.Coreformat="%LifeTime" also if you need: to get the value of a tag from a core in the code use this: batterycore1.get("%LifeTime") ============ Armando wrote: 1) shows the minutes not divided in hours (eg.: 157 minutes) ... (do not know how you become with code to hours and minutes ...). you can use like this in code to make it [hour:minute] Code: mp=parseInt("157minutes",10) h1=parseInt(mp/60,10) m1=parseInt(mp%60,10) text1.text=h1+":"+m1 you can use your own statement instead of "157minutes" in mp line: ex: using a tag: mp=parseInt( batterycore1.get("%LifeTime") , 10 ) or ex: using a variable: bm=batterycore1.get("%LifeTime") mp=parseInt( bm , 10 ) ---------------- and also if needed you should add the code to a [if] statement, since i don't have battery i don't know when it displays in minutes. --------------- Note: parseInt( numString , Radix ): A function that will make its input to int -numString: the String you want to make int -Radix: the numeral system to be used (it can be from 2-36); use 10 for decimal system ex: float>int: parseInt(12.157,10) >>> 12 ex: char>int: parseInt(123abcd,10) >>> 123 ex: float&chars>int: parseInt(153.12abcd,10) >>> 153 ================== |
Author: | Armando [ December 20th, 2013, 12:09 pm ] |
Post subject: | Re: ${LifeTime} Seems to not work |
Great!!! it's work fine, BUT numbers appear only a second and then disappear. I can only see the numbers again reloading the widget. I finally use this code: mp=parseInt(batterycore1.get("%LifeTime"),10) h1=parseInt(mp/60,10) m1=parseInt(mp%60,10) text1.text=h1+":"+m1 I put in the opening lines of code. (lines 1,2,3,4 of the script code area). should have put it somewhere else? (for example in the part of "text1 on change")? THANKS again! |
Author: | hamid [ December 20th, 2013, 4:04 pm ] |
Post subject: | Re: ${LifeTime} Seems to not work |
Armando wrote: Great!!! it's work fine, BUT numbers appear only a second and then disappear. I can only see the numbers again reloading the widget. I put in the opening lines of code. (lines 1,2,3,4 of the script code area). should have put it somewhere else? (for example in the part of "text1 on change")? THANKS again! yes, you should use it in a function. lines of the code that place outside of the function will only run at startup. this code will convert the output of %LifeTime to hour:min so it should be placed in a function that be called after each %LifeTime update use one of these that you have used in your code: -you can use it in batterycore1onupdate function since it will run after each update of batterycore or -you can use it in text1OnChange function if you bind the %LifeTime tag to it, so on each update text1 will change and the text1OnChange function will run and convert the output ============== remember that since the %LifeTime is not always in minutes you should also use it in a [if] statement. to prevent running it for other conditions. if you told me that what's the other conditions it displays i can help you more; if it displays only in 00:00 and []minutes formats so you can use the code in an [else] after your previous [if(00:00)]: Code: function text1OnChange(Sender)
{ if(text1.Text=="00:00") { text1.Text="FULL" } else { mp=parseInt(batterycore1.get("%LifeTime"),10) h1=parseInt(mp/60,10) m1=parseInt(mp%60,10) text1.text=h1+":"+m1 } } |
Author: | Armando [ December 20th, 2013, 7:34 pm ] |
Post subject: | Re: ${LifeTime} Seems to not work |
Hamid... GREAT!!! now it's working perfect!!! Thanks for all your help and teaching! I'm sure this will help others! |
Page 1 of 1 | All times are UTC - 8 hours |
Powered by phpBB® Forum Software © phpBB Group http://www.phpbb.com/ |