Re: Did numberFormat Break?
I'm sure this will start some historical flame war, but why use numberFormat (an archaic leftover from HyperCard) or invest the time to write your own? LiveCode has a great formatting function built in - format(baseString [, valuesList]) put format("%.2f",1.00+1) into tpoextprice -- does what you would get with numberFormat as "0.00" but in all circumstances See http://livecode.com/resources/api/#livecode_script/format Strike that, the entry on the web site has the formatting of the baseString options all messed up. Check the Dictionary on your copy of LiveCode instead. On 2/15/2018 12:59 PM, Bob Sneidar via use-livecode wrote: > On second thot, I think I will just use my own number formatting function. > > Bob S > > >> On Feb 15, 2018, at 09:54 , Bob Sneidar via use-livecode >>wrote: >> >> Thanks Klaus and Mike indeed you are correct. I keep making the mistake of >> reading the dictionary. ;-P I don't see anything there that refers to only >> working with containers, only that the results of the calculation is >> affected. >> >> But it's more complex than even that. Given: >> >> set the numberFormat to "0.00" >> put 0 into textprice >> put textprice >> >> displays 0, not 0.00. So a calculation *must* be performed on a variable >> *and* the variable put into a container in order for this to take effect. >> What I am going to do instead to initialize a numberic variable is to add 0 >> to a variable. >> >> The second part I am sketchy on tho. I think the script editor variable >> watcher is itself a livecode stack with livecode fields, so it ought to >> reflect the results of numberFormat, however numberFormat applies only to >> the local script it is set in, so how that could be accomplished I do not >> know. >> >> I think I will put in a feature request to update the dictionary to reflect >> this. >> >> Bob S >> >> >>> On Feb 15, 2018, at 09:34 , Klaus major-k via use-livecode >>> wrote: >>> >>> Hi Bob, >>> Am 15.02.2018 um 18:20 schrieb Bob Sneidar via use-livecode : I have this in a script: on mouseUp set the numberFormat to "0.00" put 1.00+1 into tpoextprice breakpoint >>> put tpoextprice >>> end mouseUp At this point tpoextprice is 2. Not mind you, 2.00, just 2. >>> Adding this, will put 2.00 into the message box. LC 8.1.9, Mac. >>> So maybe the debugger does just not display the correct number? >>> Either I am missing something (again) or else numberFormat is broken. Bob S >>> Best >>> >>> Klaus >>> >>> -- >>> Klaus Major >>> http://www.major-k.de >>> kl...@major-k.de >>> >>> >>> ___ >>> use-livecode mailing list >>> use-livecode@lists.runrev.com >>> Please visit this url to subscribe, unsubscribe and manage your >>> subscription preferences: >>> http://lists.runrev.com/mailman/listinfo/use-livecode >> >> ___ >> use-livecode mailing list >> use-livecode@lists.runrev.com >> Please visit this url to subscribe, unsubscribe and manage your subscription >> preferences: >> http://lists.runrev.com/mailman/listinfo/use-livecode > > ___ > use-livecode mailing list > use-livecode@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your subscription > preferences: > http://lists.runrev.com/mailman/listinfo/use-livecode > ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Did numberFormat Break?
Internally the type of “0” will be text initially which is probably why the number format isn’t applied. Any math will convert it to a number. This is something that should be addressed once we have optional type declaration for variables. On Thu, Feb 15, 2018 at 12:28 PM J. Landman Gay via use-livecode < use-livecode@lists.runrev.com> wrote: > It's not just containers, anything that converts the implicit numeric type > to text will honor numberformat. > -- > Jacqueline Landman Gay | jac...@hyperactivesw.com > HyperActive Software | http://www.hyperactivesw.com > > > > On February 15, 2018 11:56:33 AM Bob Sneidar via use-livecode >wrote: > > > Thanks Klaus and Mike indeed you are correct. I keep making the mistake > of > > reading the dictionary. ;-P I don't see anything there that refers to > only > > working with containers, only that the results of the calculation is > affected. > > > > But it's more complex than even that. Given: > > > > set the numberFormat to "0.00" > > put 0 into textprice > > put textprice > > > > displays 0, not 0.00. So a calculation *must* be performed on a variable > > *and* the variable put into a container in order for this to take effect. > > What I am going to do instead to initialize a numberic variable is to > add 0 > > to a variable. > > > > The second part I am sketchy on tho. I think the script editor variable > > watcher is itself a livecode stack with livecode fields, so it ought to > > reflect the results of numberFormat, however numberFormat applies only to > > the local script it is set in, so how that could be accomplished I do > not know. > > > > I think I will put in a feature request to update the dictionary to > reflect > > this. > > > > Bob S > > > > > >> On Feb 15, 2018, at 09:34 , Klaus major-k via use-livecode > >> wrote: > >> > >> Hi Bob, > >> > >>> Am 15.02.2018 um 18:20 schrieb Bob Sneidar via use-livecode > >>> : > >>> > >>> I have this in a script: > >>> > >>> on mouseUp > >>> set the numberFormat to "0.00" > >>> put 1.00+1 into tpoextprice > >>> breakpoint > >> > >> put tpoextprice > >> > >>> end mouseUp > >>> At this point tpoextprice is 2. Not mind you, 2.00, just 2. > >> > >> Adding this, will put 2.00 into the message box. LC 8.1.9, Mac. > >> So maybe the debugger does just not display the correct number? > >> > >>> Either I am missing something (again) or else numberFormat is broken. > >>> > >>> Bob S > >> > >> Best > >> > >> Klaus > >> > >> -- > >> Klaus Major > >> http://www.major-k.de > >> kl...@major-k.de > >> > >> > >> ___ > >> use-livecode mailing list > >> use-livecode@lists.runrev.com > >> Please visit this url to subscribe, unsubscribe and manage your > >> subscription preferences: > >> http://lists.runrev.com/mailman/listinfo/use-livecode > > > > > > ___ > > use-livecode mailing list > > use-livecode@lists.runrev.com > > Please visit this url to subscribe, unsubscribe and manage your > > subscription preferences: > > http://lists.runrev.com/mailman/listinfo/use-livecode > > > > ___ > use-livecode mailing list > use-livecode@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your > subscription preferences: > http://lists.runrev.com/mailman/listinfo/use-livecode > ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Did numberFormat Break?
It's not just containers, anything that converts the implicit numeric type to text will honor numberformat. -- Jacqueline Landman Gay | jac...@hyperactivesw.com HyperActive Software | http://www.hyperactivesw.com On February 15, 2018 11:56:33 AM Bob Sneidar via use-livecodewrote: Thanks Klaus and Mike indeed you are correct. I keep making the mistake of reading the dictionary. ;-P I don't see anything there that refers to only working with containers, only that the results of the calculation is affected. But it's more complex than even that. Given: set the numberFormat to "0.00" put 0 into textprice put textprice displays 0, not 0.00. So a calculation *must* be performed on a variable *and* the variable put into a container in order for this to take effect. What I am going to do instead to initialize a numberic variable is to add 0 to a variable. The second part I am sketchy on tho. I think the script editor variable watcher is itself a livecode stack with livecode fields, so it ought to reflect the results of numberFormat, however numberFormat applies only to the local script it is set in, so how that could be accomplished I do not know. I think I will put in a feature request to update the dictionary to reflect this. Bob S On Feb 15, 2018, at 09:34 , Klaus major-k via use-livecode wrote: Hi Bob, Am 15.02.2018 um 18:20 schrieb Bob Sneidar via use-livecode : I have this in a script: on mouseUp set the numberFormat to "0.00" put 1.00+1 into tpoextprice breakpoint put tpoextprice end mouseUp At this point tpoextprice is 2. Not mind you, 2.00, just 2. Adding this, will put 2.00 into the message box. LC 8.1.9, Mac. So maybe the debugger does just not display the correct number? Either I am missing something (again) or else numberFormat is broken. Bob S Best Klaus -- Klaus Major http://www.major-k.de kl...@major-k.de ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Did numberFormat Break?
On second thot, I think I will just use my own number formatting function. Bob S > On Feb 15, 2018, at 09:54 , Bob Sneidar via use-livecode >wrote: > > Thanks Klaus and Mike indeed you are correct. I keep making the mistake of > reading the dictionary. ;-P I don't see anything there that refers to only > working with containers, only that the results of the calculation is > affected. > > But it's more complex than even that. Given: > > set the numberFormat to "0.00" > put 0 into textprice > put textprice > > displays 0, not 0.00. So a calculation *must* be performed on a variable > *and* the variable put into a container in order for this to take effect. > What I am going to do instead to initialize a numberic variable is to add 0 > to a variable. > > The second part I am sketchy on tho. I think the script editor variable > watcher is itself a livecode stack with livecode fields, so it ought to > reflect the results of numberFormat, however numberFormat applies only to the > local script it is set in, so how that could be accomplished I do not know. > > I think I will put in a feature request to update the dictionary to reflect > this. > > Bob S > > >> On Feb 15, 2018, at 09:34 , Klaus major-k via use-livecode >> wrote: >> >> Hi Bob, >> >>> Am 15.02.2018 um 18:20 schrieb Bob Sneidar via use-livecode >>> : >>> >>> I have this in a script: >>> >>> on mouseUp >>> set the numberFormat to "0.00" >>> put 1.00+1 into tpoextprice >>> breakpoint >> >> put tpoextprice >> >>> end mouseUp >>> At this point tpoextprice is 2. Not mind you, 2.00, just 2. >> >> Adding this, will put 2.00 into the message box. LC 8.1.9, Mac. >> So maybe the debugger does just not display the correct number? >> >>> Either I am missing something (again) or else numberFormat is broken. >>> >>> Bob S >> >> Best >> >> Klaus >> >> -- >> Klaus Major >> http://www.major-k.de >> kl...@major-k.de >> >> >> ___ >> use-livecode mailing list >> use-livecode@lists.runrev.com >> Please visit this url to subscribe, unsubscribe and manage your subscription >> preferences: >> http://lists.runrev.com/mailman/listinfo/use-livecode > > > ___ > use-livecode mailing list > use-livecode@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your subscription > preferences: > http://lists.runrev.com/mailman/listinfo/use-livecode ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Did numberFormat Break?
Thanks Klaus and Mike indeed you are correct. I keep making the mistake of reading the dictionary. ;-P I don't see anything there that refers to only working with containers, only that the results of the calculation is affected. But it's more complex than even that. Given: set the numberFormat to "0.00" put 0 into textprice put textprice displays 0, not 0.00. So a calculation *must* be performed on a variable *and* the variable put into a container in order for this to take effect. What I am going to do instead to initialize a numberic variable is to add 0 to a variable. The second part I am sketchy on tho. I think the script editor variable watcher is itself a livecode stack with livecode fields, so it ought to reflect the results of numberFormat, however numberFormat applies only to the local script it is set in, so how that could be accomplished I do not know. I think I will put in a feature request to update the dictionary to reflect this. Bob S > On Feb 15, 2018, at 09:34 , Klaus major-k via use-livecode >wrote: > > Hi Bob, > >> Am 15.02.2018 um 18:20 schrieb Bob Sneidar via use-livecode >> : >> >> I have this in a script: >> >> on mouseUp >> set the numberFormat to "0.00" >> put 1.00+1 into tpoextprice >> breakpoint > > put tpoextprice > >> end mouseUp >> At this point tpoextprice is 2. Not mind you, 2.00, just 2. > > Adding this, will put 2.00 into the message box. LC 8.1.9, Mac. > So maybe the debugger does just not display the correct number? > >> Either I am missing something (again) or else numberFormat is broken. >> >> Bob S > > Best > > Klaus > > -- > Klaus Major > http://www.major-k.de > kl...@major-k.de > > > ___ > use-livecode mailing list > use-livecode@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your subscription > preferences: > http://lists.runrev.com/mailman/listinfo/use-livecode ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Did numberFormat Break?
If I recall what I read way back, I think the numberrformat only applies to containers other than variables. If you were to put tpoextprice into field "field" the numberformat should be applied correctly. I think the reason for this is that numberformat can be used to add non-number chars ($) but the number in the variable needs to remain a number. Its only when its dropped somewhere that the changes are applied. On Thu, Feb 15, 2018 at 10:20 AM, Bob Sneidar via use-livecode < use-livecode@lists.runrev.com> wrote: > I have this in a script: > > on mouseUp >set the numberFormat to "0.00" >put 1.00+1 into tpoextprice >breakpoint > end mouseUp > > At this point tpoextprice is 2. Not mind you, 2.00, just 2. > > Either I am missing something (again) or else numberFormat is broken. > > Bob S > > > ___ > use-livecode mailing list > use-livecode@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your > subscription preferences: > http://lists.runrev.com/mailman/listinfo/use-livecode > ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Did numberFormat Break?
Hi Bob, > Am 15.02.2018 um 18:20 schrieb Bob Sneidar via use-livecode >: > > I have this in a script: > > on mouseUp > set the numberFormat to "0.00" > put 1.00+1 into tpoextprice > breakpoint put tpoextprice > end mouseUp > At this point tpoextprice is 2. Not mind you, 2.00, just 2. Adding this, will put 2.00 into the message box. LC 8.1.9, Mac. So maybe the debugger does just not display the correct number? > Either I am missing something (again) or else numberFormat is broken. > > Bob S Best Klaus -- Klaus Major http://www.major-k.de kl...@major-k.de ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Did numberFormat Break?
I have this in a script: on mouseUp set the numberFormat to "0.00" put 1.00+1 into tpoextprice breakpoint end mouseUp At this point tpoextprice is 2. Not mind you, 2.00, just 2. Either I am missing something (again) or else numberFormat is broken. Bob S ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode