Europen (or other) number style
Posted: Mon Oct 21, 2013 2:21 pm
I used the following code for money in European (comma) format, example:
however it can be used as any other number format conversion:
I suggest to use always standard Livecode format for numbers and convert them just for display values.
Code: Select all
europenum 12345.6
== 12'345,60
Code: Select all
function reversed pString
local tReversedString
repeat with tChar = the length of pString down to 1
put char tChar of pString after tReversedString
end repeat
return tReversedString
end reversed
function europenum mynum
set itemdelimiter to "."
put the first item of mynum into integ
put the second item of mynum into decimal
if decimal is not empty then
#this is optiona for money values
if length(decimal) = 1 then
put 0 after decimal
end if
##
put "," before decimal
else
put ",00" into decimal #money values
end if
put 1 into n
put reversed(integ) into integ
repeat for each char numb in integ
if n = 4 then
put "'" before decimal
put 1 into n
end if
put numb before decimal
add 1 to n
end repeat
return decimal
end europenum