setting "numberFormat" for a field?

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!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
homer
Posts: 20
Joined: Fri Jun 29, 2007 6:44 pm

setting "numberFormat" for a field?

Post by homer » Sun Aug 05, 2007 6:16 pm

I know this sounds like a stupid question. I looked thru the documentation and I couldn't figure out or find a good example.

I have a field where I am putting a value.

I want to set the numberFormat for that value to ^^^^.^^, that is four place holders, a decimal point, and two placeholders after that.

I have another field where I want the numberFormat to be ^^.^^^^

do I put that into a script for the field? how?

do I declare it at the beginning of the stack? how?

assistance is very much appreciated.

homer

Mark Smith
Posts: 179
Joined: Sat Apr 08, 2006 11:08 pm
Contact:

Post by Mark Smith » Sun Aug 05, 2007 6:49 pm

Homer, I don't think you can set this as a property of a field.

One way to achieve it would be to have a 'dummy setProp' handler in the script of the field:

Code: Select all

setProp formatNumber pNumber
  put format("%07.2f", pNumber) into me
end formatNumber
(that would be "%07.4f" for your other field)

Then, whenever you want to update that field, you'd do this:

Code: Select all

set the formatNumber of fld "theField" to someNumber
Hope this helps,

Mark

Post Reply