Hi team, I'm at the very begining of my learning curve with LC and therefore please excuse me for this basic question. As a disclaimer before posting I spen a considerable amount of time searching on all available documentation and wasn't able to find the answer...
Assuming on a given field I have a number 12345678912 and when closing the field I want it to look like this: 123.456.789,12 (123,456,789.12 will also work).
How should I do it?
Many thanks in advance...
Number formatting
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 665
- Joined: Tue Jul 29, 2014 12:52 am
Number formatting
Simon
________________________________________
To ";" or not to ";" that is the question
________________________________________
To ";" or not to ";" that is the question
Re: Number formatting
Hi Simon,
Not sure that is the best way but this script do it
Best regards
Jean-Marc
Not sure that is the best way but this script do it
Code: Select all
on mouseUp
put "12345678912" into t0
put empty into t1
put "," & char -2 to -1 of t0 into t1
put char -5 to -3 of t0 before t1
put char -8 to -6 of t0 & "." before t1
put char -11 to -9 of t0 & "." before t1
answer t1 & cr & "123.456.789,12 expected"
end mouseUp
Jean-Marc
https://alternatic.ch
-
- Posts: 665
- Joined: Tue Jul 29, 2014 12:52 am
Re: Number formatting
Jean-Marc, many thanks it works as expected!
Best!
Best!
Simon
________________________________________
To ";" or not to ";" that is the question
________________________________________
To ";" or not to ";" that is the question
Re: Number formatting
Great,
but I guess you need the same for other numbers.
Function return a value and it is a good way
Something like this
All the best
Jean-Marc
but I guess you need the same for other numbers.
Function return a value and it is a good way
Something like this
Code: Select all
on mouseUp
put setMynumber(12345678912)-- the result to message box
end mouseUp
function setMynumber pNumber
put pNumber into t0
put empty into t1
put "," & char -2 to -1 of t0 into t1
put char -5 to -3 of t0 before t1
put char -8 to -6 of t0 & "." before t1
put char -11 to -9 of t0 & "." before t1
return t1
end setMynumber
Jean-Marc
https://alternatic.ch