Dollar value defined fields
Moderator: Klaus
Dollar value defined fields
I wish there was a simple was to define fields as dollar values with $ signs and commas inserted by the system, Thanks
Re: Dollar value defined fields
Hi.
Kind of how Excel does it? As a textStyle?
This would be a convenience, I suppose, but is so simple to implement as a function that it is not likely to excite the LC team. Do you need any help at all in writing such a function, or storing it in a place where it would be accessible across LC?
Craig Newman
Kind of how Excel does it? As a textStyle?
This would be a convenience, I suppose, but is so simple to implement as a function that it is not likely to excite the LC team. Do you need any help at all in writing such a function, or storing it in a place where it would be accessible across LC?
Craig Newman
-
- Livecode Opensource Backer
- Posts: 10081
- Joined: Fri Feb 19, 2010 10:17 am
Re: Dollar value defined fields
I wonder what would "excite the LC team" as almost none of the feature requests seem to be even acknowledged.
Re: Dollar value defined fields
Yes like excel would be great. But if that can't happen I do need some help
I use this complicated code to display the field properly as a dollar value then when I go to use it on a later card
the commas and $ don't allow it to be recogonized as a number so I don't know what to do
on mouseUp --format number with commas
put fld c1 && MoneyFormat(fld money) into fld money
end mouseUp
function MoneyFormat TheValue --123456789.9876 to $123,456,789.99
local TheDecimal
set the numberFormat to "0.00" --money
put TheValue * 1 into TheValue --calc to convert
set the itemDel to "."
if item -1 of TheValue <> empty then
put item -1 of TheValue into TheDecimal
delete item -1 of TheValue --decimal number
end if
set the itemDel to "," --default
repeat with i = length(TheValue)-3 down to 3 step -3
put comma after char i of TheValue
end repeat
set the numberFormat to "0.######" --default
return "$"& TheValue &"."& TheDecimal --money
end MoneyFormat
There must be an easier way my app uses large $ values HELP!
I use this complicated code to display the field properly as a dollar value then when I go to use it on a later card
the commas and $ don't allow it to be recogonized as a number so I don't know what to do
on mouseUp --format number with commas
put fld c1 && MoneyFormat(fld money) into fld money
end mouseUp
function MoneyFormat TheValue --123456789.9876 to $123,456,789.99
local TheDecimal
set the numberFormat to "0.00" --money
put TheValue * 1 into TheValue --calc to convert
set the itemDel to "."
if item -1 of TheValue <> empty then
put item -1 of TheValue into TheDecimal
delete item -1 of TheValue --decimal number
end if
set the itemDel to "," --default
repeat with i = length(TheValue)-3 down to 3 step -3
put comma after char i of TheValue
end repeat
set the numberFormat to "0.######" --default
return "$"& TheValue &"."& TheDecimal --money
end MoneyFormat
There must be an easier way my app uses large $ values HELP!
Re: Dollar value defined fields
use a setProp handler to store the numeric value and the display value on the field together, as per this thread
http://forums.livecode.com/phpBB2/viewt ... 696#p12696
http://forums.livecode.com/phpBB2/viewt ... 696#p12696
-
- VIP Livecode Opensource Backer
- Posts: 10043
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Dollar value defined fields
GetProp/setProp are handy, but only work if no script locks messages. This is slated to be fixed, but it's been a while since that was decided so I don't know when we'll see it implemented.SparkOut wrote:use a setProp handler to store the numeric value and the display value on the field together, as per this thread
http://forums.livecode.com/phpBB2/viewt ... 696#p12696
So in the meantime, as much as I like the idea of property triggers, I stick with humble getter/setter functions and commands for now.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Dollar value defined fields
It will take me some time to sort out this new code and where to put it. This is just my first month
so on dollar fields I am using a separate field to display the $ sign and rounding off the decimal values and ignoring the
commas. Its simple but works good with the exemption of the missing commas
the rounding is OK because the cents don't matter for the application.
Thanks for the homework when I get some time I will try to figure out how to do it right
so on dollar fields I am using a separate field to display the $ sign and rounding off the decimal values and ignoring the
commas. Its simple but works good with the exemption of the missing commas
the rounding is OK because the cents don't matter for the application.
Thanks for the homework when I get some time I will try to figure out how to do it right

Re: Dollar value defined fields
Hi.
Make a field "arg" with this in its script. You will also need another field "f1". You mentioned homework. That is my bailiwick.
Your homework is to play with the code and learn as much as you can about it.
Craig
Make a field "arg" with this in its script. You will also need another field "f1". You mentioned homework. That is my bailiwick.
Your homework is to play with the code and learn as much as you can about it.
Code: Select all
on returnInField
put digitToWord(fld "arg") into fld "f1"
end returnInField
function digitToWord theDigits
put "One,Two,Three,Four,Five,Six,Seven,Eight,Nine" into ones
put "Ten,Eleven,Twelve,Thirteen,Fourteen,Fifteen,Sixteen,Seventeen,Eighteen,Nineteen" into teens
put ",Twenty,Thirty,Forty,Fifty,Sixty,Seventy,Eighty,Ninety" into tens
set numberformat to "#.00"
if "."is not in theDigits then put ".00" after theDigits
get offset(".",theDigits)
if it > 7 then
answer "You can't afford to write this check"
exit to top
end if
get offset(".",theDigits)
if char it + 1 of theDigits = "" then put "00" after theDigits
if it <> 0 then put " Dollars and" && char it + 1 to it + 2 of theDigits & "/100" into temp
delete char it to it + 2 of theDigits
get number(chars of theDigits)
if char it - 1 of theDigits = 1 then put item char it of theDigits + 1 of teens before temp
else
put item char it of theDigits of ones before temp
put item char it - 1 of theDigits of tens & space before temp
end if
if it >= 3 and char it - 2 of theDigits <> 0 then put item char it - 2 of theDigits of ones && "Hundred" & space before temp
if it = 4 then put item char it - 3 of theDigits of ones && "Thousand" & space before temp
if it = 5 and char 1 of theDigits = 1 then put item (char it - 3 of theDigits + 1) of teens && "Thousand" & space before temp
else if it = 5 then put item char it - 4 of theDigits of tens && item char it - 3 of theDigits of ones && "Thousand" & space before temp
if it = 6 then put item char 1 of theDigits of ones && "Hundred" && item char 2 of theDigits of tens && item char 3 of theDigits of ones & " Thousand " before temp
return temp
end digitToWord
Last edited by dunbarx on Mon May 25, 2015 5:49 am, edited 1 time in total.
Re: Dollar value defined fields
thanks I'll give it a try
Re: Dollar value defined fields
Mike.
The gadget I gave you does sort of the opposite of what you asked for. It is something to step through when you have nothing better to do. It is possibly useful if you want to go all around your original feature request. Take your time...
Craig
The gadget I gave you does sort of the opposite of what you asked for. It is something to step through when you have nothing better to do. It is possibly useful if you want to go all around your original feature request. Take your time...
Craig