I have been coming across this issue more and more when dealing with JavaScript and JSON which is ColdFusion changing true|false to YES|NO values.
For example:-
<cfset foo = true />
<cfoutput>#foo#</cfoutput> = true
<cfset foo = !foo />
<cfoutput>#foo#</cfoutput> = NO
Now take this JSON string for example
{“foo”:#foo#} would then become {“foo”:NO} which then screws everything up
I posted a feature request on the adobe site to have a toBoolean() function which would return only true or false based on the argument
So then we would be able to have...
{“foo”:#toBollean(foo)#} which would output as {“foo”:false}
What are the thoughts here. I was very surprised to see the lack of this function in the library actually.
Also can anyone one recommend a way to do this now? I tried JavaCast(“Boolean”, foo) but that didn’t work.
Steve
z
> --
> You received this message because you are subscribed to the Google Groups
> "cfaussie" group.
> To post to this group, send email to cfau...@googlegroups.com.
> To unsubscribe from this group, send email to
> cfaussie+u...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/cfaussie?hl=en.
>
--
Zac Spitzer
Solution Architect / Director
Ennoble Consultancy Australia
http://www.ennoble.com.au
http://zacster.blogspot.com
+61 405 847 168
have you seen this?
http://www.coldfusionmuse.com/index.cfm/2010/2/5/Booleans.and.Coldfusion
Also, have you confirmed you have a true boolean? What I'm getting at
is the difference between
True/False/Null (tri-state)
True/Absence of True (boolean)
The last one is important because you just have to check to see if the
value is there.
these two CFLib functions may help
http://cflib.org/udf/booleanize
http://cflib.org/udf/forceBoolean
I want it to be true|false
I want !true to give me false, not NO
-----Original Message-----
From: Zac Spitzer [mailto:zac.s...@gmail.com]
Sent: Thursday, 4 August 2011 4:56 PM
To: cfau...@googlegroups.com
Subject: Re: [cfaussie] Converting boolean YES to true
The calculation is like this
<cfset somevar = false />
<cfset foo = (!somevar) AND true />
The above will give me "YES" as the result where i want it to give me
"true". This is the issue
I have gotten around it with
<cfset foo = IIF((!somevar) AND true, "true", "false") />
It is a bit of a hack but i don’t really like it.
-----Original Message-----
From: Barry Beattie [mailto:barry....@gmail.com]
Sent: Thursday, 4 August 2011 5:02 PM
To: cfau...@googlegroups.com
Subject: Re: [cfaussie] Converting boolean YES to true
Yeah it can be fixed with if/else but should it be? We want to write “less” code, not more...true ? or maybe it is YES J
is anything that can be construed as a YES (True, 1, etc) considered a
YES and therefore the opposite is NO?
> --
> You received this message because you are subscribed to the Google Groups
> "cfaussie" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/cfaussie/-/-amD6_MZprcJ.
#(value ? "true" : "false" )#There you go.CF is dynamic, so true is YES is 1... if you want static values, use a static language. There are pros and cons both ways.
Mark--
They can leave it as it is. If they add a toBoolean() function then the existing functionality can remain but we can use this function to actually give a proper Boolean value
From: Chong [mailto:kck...@gmail.com]
Sent: Thursday, 4 August 2011 5:31 PM
To: cfau...@googlegroups.com
Subject: Re: [cfaussie] Converting boolean YES to true
TBH you would have to fix it yourself, I can't see Adobe fixing it soon as it is likely a legacy issue, I would imagine if they change how it works to the way we expect it should, any code using specifically the old behaviour would error ... so they are probably stuck till they can agree on an elegant solution or give clients enough warning...
--
You received this message because you are subscribed to the Google Groups "cfaussie" group.
To view this discussion on the web visit https://groups.google.com/d/msg/cfaussie/-/-amD6_MZprcJ.