Format number
Moderators: heatherlaine, kevinmiller, robinmiller, Zryip TheSlug
Format number
I have downloaded the DGH trial. I followed the lessons to be able to format a field "### ## 0.00", decimal separator "," and separator of thousands ".". I do not get an error but it does not format it. It can be a limitation of the trial?
Regards,
Carles
Regards,
Carles
-
- VIP Livecode Opensource Backer
- Posts: 2262
- Joined: Thu Feb 28, 2013 11:52 pm
- Location: Göttingen, DE
Re: Format number
These separators don't work with the usual number format.
I don't use/know DataGrid but here is function that does with every LiveCode field what you want. You have to input your numbers (with comma as decimal separator) and then hit enter to get the field formatted as "thousands.hundreds,decimals".
I don't use/know DataGrid but here is function that does with every LiveCode field what you want. You have to input your numbers (with comma as decimal separator) and then hit enter to get the field formatted as "thousands.hundreds,decimals".
Code: Select all
-- [by -hh] script for a field with the wanted
-- number format "thousands.hundreds,decimals"
-- input numbers using "," as decimal separator!
local sc -- the selectedChunk
function myNumberFormat x
if x > 1000 then
put (x div 1000) & "." into thsnd
else put empty into thsnd
put x mod 1000 into hndrd
put format("%0.2f",hndrd) into hndrd
replace "." with "," in hndrd
put thsnd & hndrd into txt
put 1+length(x) - length(txt) into d
add d to word 2 of sc
add d to word 4 of sc
return thsnd & hndrd
end myNumberFormat
on enterInField
put the selectedChunk into sc
put me into txt
replace "." with empty in txt
replace "," with "." in txt
if txt is not a number then
put myNumberFormat(0) into me
exit enterInfield
end if
put myNumberFormat(txt) into me
select sc
end enterInField
on returnInField
enterInField
end returnInField
shiftLock happens
Re: Format number
Thanks for the reply [-hh].
I have usually replaced "," by "." and "." by ",", to make it look good on the screen, and to save it to the database to reverse the operation.
According to the lesson on the dgH plugin, this format is correct, but it does not work out for me. http://lessons.livecode.com/m/4068/l/39 ... r-a-column
Regards,
Carles
I have usually replaced "," by "." and "." by ",", to make it look good on the screen, and to save it to the database to reverse the operation.
According to the lesson on the dgH plugin, this format is correct, but it does not work out for me. http://lessons.livecode.com/m/4068/l/39 ... r-a-column
Regards,
Carles
-
- VIP Livecode Opensource Backer
- Posts: 2262
- Joined: Thu Feb 28, 2013 11:52 pm
- Location: Göttingen, DE
Re: Format number
Decimal separator is always the period (".").
How did you script the replacement?
How did you script the replacement?
shiftLock happens
Re: Format number
Hi,
Column Builder's Format, in the Decimal separator. Not In the Pattern property
Column Builder's Format, in the Decimal separator. Not In the Pattern property
-
- VIP Livecode Opensource Backer
- Posts: 2262
- Joined: Thu Feb 28, 2013 11:52 pm
- Location: Göttingen, DE
Re: Format number
I know why I don't use DG. I do it all by myself. That works, and if not I know why
shiftLock happens
Re: Format number
I guess you should take more than three weeks with LiveCode
-
- VIP Livecode Opensource Backer
- Posts: 163
- Joined: Tue Jan 26, 2010 10:15 pm
- Contact:
Re: Format number
I was in touch with Carles and found he didn't installed the DGH's script into the column to format.
The problem is now solved. Thanks guys for the help.
The problem is now solved. Thanks guys for the help.
TheSlug
http://www.aslugontheroad.com - Tutorials, demo stacks and plugins for LiveCode
Data Grid Helper - An intuitive interface for building LiveCode's Data Grids
Excel Library- Extends the LiveCode language for controlling MS Excel
http://www.aslugontheroad.com - Tutorials, demo stacks and plugins for LiveCode
Data Grid Helper - An intuitive interface for building LiveCode's Data Grids
Excel Library- Extends the LiveCode language for controlling MS Excel