LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!
I have attached some code below. I am having trouble formatting the data in the fields, having had a number of attempts. What is the correct cods and where does it go?
repeat with n = 1 to 12
if fld ("UOM"&n) = "gm" then
put fld ("QTY"&n)/1000 into tQTY
else
put fld ("QTY"&n) into tQTY
end if
put fld ("cost"&n) * tQTY into tsubtotal
put tsubtotal into fld ("subtotal"&n)
add tQTY to tTotalQty
add fld ("subtotal"&n) to tTotalCost
fld ("subtotal"&n) is a dollar figure. When I put the format #.00 command in the line before it formats the "n" and screws the script!!
repeat with n = 1 to 12
if fld ("UOM"&n) = "gm" then
put fld ("QTY"&n)/1000 into tQTY
else
put fld ("QTY"&n) into tQTY
end if
put fld ("cost"&n) * tQTY into tsubtotal
--set the numberformat to "#.00"
put tsubtotal into fld ("subtotal"&n)
add tQTY to tTotalQty
add fld ("subtotal"&n) to tTotalCost
end repeat
I used the "set the number format and what happens is that it sets the number format of "n" to #.00 and the script wil not run.
What does "the script does not run" mean? Do you get an error message? If you get an error message, you should always post it together with your question on this forum.
Does the following script work for you? If not, where does it go wrong? Do you still get an error message?
repeat with n = 1 to 12
if fld ("UOM"&n) = "gm" then
put fld ("QTY"&n)/1000 into tQTY
else
put fld ("QTY"&n) into tQTY
end if
put fld ("cost"&n) * tQTY into tsubtotal
set the numberformat to "#.00"
put tsubtotal*1 into tsubtotal
set the numberformat to "#"
put tsubtotal into fld ("subtotal"&n)
add tQTY to tTotalQty
add fld ("subtotal"&n) to tTotalCost
end repeat
Best,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode