Page 1 of 1
Change "," with "." one mouseUp with - if there is???
Posted: Tue Oct 08, 2019 7:30 pm
by UrosDobricic
Hi,
i have made an app, where Users can put values in fields (numeric values) and then calculate with them.
Now there is the good known problem, that when the user type "0,35" the function does not work.
My thought was to replace the "," with "." on mouseUp.
I wrote :
Code: Select all
If there is a "," in field "kapmm" then
replace "," with "."
end if
But it won´t work like that.
What is the problem with this peace of code?
Any ideas?
Thank you for helping me out!!!
Regards,
Urosch
Re: Change "," with "." one mouseUp with - if there is???
Posted: Tue Oct 08, 2019 7:37 pm
by Klaus
Hi Uros,
oops, sorry, just came from the german forum...
Du benötigst aber keine IF Abfrage hier, wenn kein Komma im Feld ist, kann es auch nicht ersetzt werden!
No need for a IF THEN clause here, if there is no comma in that field, it cannot be replaced!
Code: Select all
...
replace "," with "." in fld "kapmm"
...
Du wolltest aber fragen:
But you wanted to check:
Code: Select all
...
if fld "kapmm" CONTAINS "," then
## Oder :
## if "," is IN fld "kapmm" then
## Many ways to skin a cat in LC :-)
## Do your thing...
end if
...
Gruß
Klaus
Re: Change "," with "." one mouseUp with - if there is???
Posted: Tue Oct 08, 2019 7:43 pm
by UrosDobricic
Hallo Klaus,
schnell und richtig wie immer
Vielen lieben Dank.
Uros
Re: Change "," with "." one mouseUp with - if there is???
Posted: Tue Oct 08, 2019 7:46 pm
by UrosDobricic
Ich möchte das versuchen, da ich mit der Methode "mit_comma" und "ohne_comma" von dir
irgendwie bugs habe auf meinem Android handy.
Er wiederholt die nummer nach dem , im Feld einfach nochmal, und der Benutzer muss die zweifache Zahl löschen.
Wüsstest du woran das liegen könnte?
Beste Grüße,
Uros
Re: Change "," with "." one mouseUp with - if there is???
Posted: Tue Oct 08, 2019 8:01 pm
by Klaus
Don't forget, this is the ENGLISH LC forum.
But the script is identical as in the IDE?
No, sorry, no idea, I do not own any mobile device, so cannot test, just check the script(s).
Re: Change "," with "." one mouseUp with - if there is???
Posted: Tue Oct 08, 2019 8:03 pm
by UrosDobricic
Sorry, of course i have to write in english.
I dont know why he is repeating my number when the user types in with this function:
Code: Select all
function ohne_komma tZahl
replace "." with "" in tZahl
replace "," with "." in tZahl
return tZahl
end ohne_komma
function mit_komma tZahl
replace "." with "," in tZahl
return tZahl
end mit_komma
My code inside the "berechnen" button looks like this:
Code: Select all
on mouseDown
put field "kapmm" into kapmm
put ohne_komma(kapmm)^2 into kapkvadrat
put field "hauptmm" into hauptmm
put ohne_komma(hauptmm)^2 into hauptkvadrat
put kapkvadrat / hauptkvadrat into faktor
put faktor * field "kapm" into zwischenrechnung
put mit_komma(round(zwischenrechnung,2)) into field "hauptm"
end mouseDown
on mouseUp
put field "schlagmm" into schlagmm
put field "schlagm" into schlagm
put ohne_komma(schlagmm)^2 into schlagkvadrat
put hauptkvadrat / schlagkvadrat into faktor2
put (schlagm-zwischenrechnung)*faktor2 into fuellschnurm
put "Die benötigte Füllschnurlänge in Meter beträgt : " & mit_komma(round(fuellschnurm*-1,2)) into field antwort
put "Auf die Rolle passen in Meter insgesamt : "& the value of field "hauptm" into line 2 of field antwort
end mouseUp
Regards,
Uros
Re: Change "," with "." one mouseUp with - if there is???
Posted: Tue Oct 08, 2019 8:20 pm
by Klaus
And in the IDE everything works as exspected?
If not please supply some example data (for kapkvadrat etc.) and I will check it.
Re: Change "," with "." one mouseUp with - if there is???
Posted: Tue Oct 08, 2019 8:24 pm
by UrosDobricic
Yes, in the IDE it works perfectly.
I dont understand the reason, but i managed it with putting this into every field:
Code: Select all
on closeField
replace "," with "." in me
end closeField
When i type into the field in my Android phone for example 0,35 i get 0,30,35