I assume the issue is with a device that uses a comma as the decimal point. Maybe set a variable with the amount then use the substitute command to replace the comma with a decimal point, then getasnumber.
That's what I thought but I set my Iphone so the comma is the decimal separator and I don't get any erroneous evaluation.
The problem is so strange and frustrating .
If I was able to reproduce it , I guess it would be an extremely simple fix.
I'm speculating that your device is set for the English language and the device that is having the issue is European. So the comma is being evaluated differently, hence the reason you can't duplicate. I would convert the . to a , and test on the European device. Using the GetAsNumber on a English device is causing the , to be dropped. On a European device it would not be dropped.
If speed one is in metres or mph and on the other is km etc. it would give different results.
I finally was able to get erroneous results on my iphone by setting it to Language English/Region France
Now that I'm able to reproduce the error I can work on a fix.
The getasnumber function has some really strange issues with the comma as the decimal separator (I may make another post detailing them).
May be use Substitute(text; ","; ".")
I created a custom function to improve the GetAsNumber() function.
With best regards Magnus Fransson.
/* Custom function for improved GetAsNumber() Syntax: ~GetAsNumber ( text ) */ Let ( [ Comma = Left( 1/2 ; 1 ) ; Improved = Substitute ( text ; [ "." ; Comma ] ; [ "," ; Comma ] ) ; Result = GetAsNumber( Improved ) ] ; Result )
Some things I noticed with my multiple tests today
All done on my iphone with France as the Region
Show Custom Dialog (Getasnumber(get(scriptparameter))
Test1 ("0.25") = 0,25
Show Custom Dialog (Getasnumber($speed))
Open URL "myscheme://~/myapp.fmp12?&Script=test2&$speed=0.25" = 25
Show Custom Dialog (Getasnumber("\""&$speed&"\""))
Open URL "myscheme://~/myapp.fmp12?&Script=test2&$speed=0.25" = .25
Based on these observations I just added this simple line to my script and it seems to have fixed the problem
Set variable $speed ==> "\"" & $speed & "\""
Then getasnumber($speed) will evaluate correctly
I actually had plenty of solutions that worked but this one seems simpler .
Not sure why it works that way but I guess it's related to the way the parameters are managed by the Open URL function