coldfusion - How do I prevent strings containing the word "yes" or "no" from printing out as true or false? -


i'm setting number of variables so:

<cfset printpage = "yes"> 

eventually, when print these variables out, try set "yes" prints out "true". set "no", prints out "false". i'm not opposed using yesnoformat function. in fact might end using function in application, in mean time know if coldfusion storing words "yes" , "no" in memory, or if converting them boolean format behind scenes.

if cf storing variables way declare them, how go retrieving these variables strings? if cf changing variables in way, there special characters or keywords use force store variables strings?

thank commented / answered. did little more experimenting , reading, , seems serializejson function automatically convert "yes" "true" , "no" "false". either need deal problem in javascript, or can add space in affected properties circumvent behavior.

you know how display boolean value "yes" or "no" (using yesnoformat()). don't think there way force coldfusion store variable way. doesn't support that. guess call out java type directly using javacast(). don't see why want go through work this. can research bit more if like. here link document javacast.

have @ document regarding data types in coldfusion. post of relevant points document here please read page more information.

coldfusion referred typeless because not assign types variables , coldfusion not associate type variable name. however, data variable represents have type, , data type affects how coldfusion evaluates expression or function argument. coldfusion can automatically convert many data types others when evaluates expressions. simple data, such numbers , strings, data type unimportant until variable used in expression or function argument.

coldfusion variable data belongs 1 of following type categories:

simple 1 value. can use directly in coldfusion expressions. include numbers, strings, boolean values, , date-time values.

binary raw data, such contents of gif file or executable program file.

complex container data. represent more 1 value. coldfusion built-in complex data types include arrays, structures, queries, , xml document objects. cannot use complex variable, such array, directly in coldfusion expression, can use simple data type elements of complex variable in expression. example, one-dimensional array of numbers called myarray, cannot use expression myarray * 5. however, use expression myarray[3] * 5 multiply third element in array five.

objects complex constructs. encapsulate both data , functional operations.

it goes on regarding data types:

data type notes
although coldfusion variables not have types, convenient use “variable type” shorthand type of data variable represents.

coldfusion provides following functions identifying data type of variable:

  • isarray
  • isbinary
  • isboolean
  • isimage
  • isnumericdate
  • isobject
  • ispdfobject
  • isquery
  • issimplevalue
  • isstruct
  • isxmldoc

coldfusion includes following functions determining whether string can represented or converted data type:

  • isdate
  • isnumeric
  • isxml

so in code use isboolean(printpage) check if contains boolean value. of course doesn't mean stored boolean coldfusion can interpret it's value boolean.


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -