Questions around th...
 
Notifications
Clear all

We appreciate the contributions many of you have been able to make towards repairing the storm damage and keeping a roof over our heads. With your help we’ve been able to complete much of the critical work. There is still work to be done to secure the house and your continued support will be a huge help.

Guests have read-only access to our forums. If you wish to participate you will need to register. Be sure to activate your account from the email sent to you when you register.

Questions around the use of . (dot) and , (comma) based values & calulations

7 Posts
2 Users
1 Reactions
211 Views
(@coolzero)
Active Member Registered
Joined: 4 weeks ago
Posts: 3
Topic starter  
I've been working with DesktopInfo (version 3.21.0.4966) and encountered some questions related to the use (. and ,) based values in calculations. Used this as an example, to learn / find out how to calulate with values.

Example from: desktopinfo-advanced.ini here is a . used in the calculations:
    - {{%CurrentTemperature% removed link }}[1.1f]°C
    - set:mbtemp={{%CurrentTemperature% removed link }}[1.0f]C
     
When I load this configuration, I get Null as the result.

see img: _1.png

Do did some digging:

desktopinfo-advanced.ini us using the MSAcpi_ThermalZoneTemperature WMI class to get temperature but it requires elevated privileges (i do not have on this machine) and trough `wbemtest` lookup my fields are empty

I switched to using Win32_PerfFormattedData_Counters_ThermalZoneInformation (e.g., Temperature or HighPrecisionTemperature), which gives a value in Kelvin, so i though thats it. But However the result was still Null.

After some reading the docs, i tried remove the . (dot) and used \, escape (comma) and the calculation works, and I get a value as result displayed.
 
Ive included my desktopinfo ini file where my test can be found. To get it working I ended up with rewriting the . into , (not escaped) to be able to use the values within DesktopInfo, and do my calulations..

PS, charts doenst have any issues with using the value, with/without escaping or that it has a . or , aka it works with all < what my espected behavior is how it should work..

see img: _2.png

So im wondering: 
    - Does DesktopInfo support calculations with . as the decimal separator?
        - Or is this a bug in the desktopinfo-advanced.ini?
        - Or is this a bug in the calculation, that it should support a . (dot) value, like charts do ?

    - Is this behavior of only supporting , (comma) based values in calculation intentional? 

    - I am receiving data from curl (through -w with reformated values), and the results contain . as decimal separators.
      Since DesktopInfo seems to require , (comma) for decimal points in calculations, I need to reformat the incoming data.
   
      Is there any in-built way to handle this?
This topic was modified 3 weeks ago 2 times by CoolZero

   
Quote
Glenn
(@glenn)
Member Admin
Joined: 8 years ago
Posts: 1867
 

I suspect you are in a location where the decimal separator is a comma?


   
ReplyQuote
(@coolzero)
Active Member Registered
Joined: 4 weeks ago
Posts: 3
Topic starter  
No, the opposite — main values contain a dot. The main issue is that I want to use the output of curl directly into DesktopInfo through the --write-out option, making use of the variables:
"%{time_appconnect}", "%{time_connect}", "%{time_namelookup}", "%{time_pretransfer}", "%{time_redirect}", "%{time_starttransfer}", "%{time_total}"

The results are:

curl -s removed link -w "@curlformat.txt"
    time_namelookup: 0.030
    time_connect: 0.041
    time_appconnect: 0.000
    time_pretransfer: 0.042
    time_redirect: 0.000
    time_starttransfer: 0.054
    time_total: 0.054
         
These are all values with a dot (.) (in seconds). They don't work, or any other value containing a . dot cannot be used for calculations. I wanted to convert them into milliseconds when i discovered that . (dot) values dont work and , (comma) values do.

So i was wondering what is the normal behavior for calculations, because Charts do accept . (dot) and ,  (comma) values so i was suppriced it wasnt working. Even that the advance.ini has calulations with a . (dot) inside them (but they also not working for me).


   
ReplyQuote
Glenn
(@glenn)
Member Admin
Joined: 8 years ago
Posts: 1867
 

Posted by: @coolzero

So i was wondering what is the normal behavior for calculations, because Charts do accept . (dot) and ,  (comma) values so i was suppriced it wasnt working. Even that the advance.ini has calulations with a . (dot) inside them (but they also not working for me).

The normal behaviour is that the expression evaluator works correctly with a dot as a decimal separator, hence the inclusion of the temperature calculation in the advanced ini.  

It won't work properly if the Windows regional settings uses a comma as a decimal separator. That is the bug.


   
ReplyQuote
(@coolzero)
Active Member Registered
Joined: 4 weeks ago
Posts: 3
Topic starter  

Ahh, check. And indeed my system is indeed with a , (comma) as decimal simbol...


   
Glenn reacted
ReplyQuote
Glenn
(@glenn)
Member Admin
Joined: 8 years ago
Posts: 1867
 

@coolzero While I work out how to deal with this, there is a work-around:

Add the following section to the ini file before the [items] section

[functions]
K2C=%1/10-273,15


[items]
...

This creates a function to do the conversion allowing use of the comma as a decimal separator.  %1 is a value passed in to the function.

In the temperature item, replace the temperature calculation with a call to the function.

WMI=interval:10,id:temp,hide-no-result:1,maxrows:1,text:Cpu Temp, set:mbtemp={{K2C:%CurrentTemperature%}}[1.0f]C,\
  namespace:root\wmi,query:MSAcpi_ThermalZoneTemperature, hidden:1

 

This gets around the issue of the comma trashing the expression.


   
ReplyQuote
Glenn
(@glenn)
Member Admin
Joined: 8 years ago
Posts: 1867
 

So I've given this some thought. The only solution I can think of is to force the decimal separator to be '.' inside the math functions so that we can distinguish between a floating point value and two values.  


   
ReplyQuote
Glenn's Page