Doing this is _slightly_ involved -- it really depends what types your
interested in... part of the problem stemming from the fact that some
types are only available in certain versions of CF and part of the
problem stemming from the fact that some types are reported as being
the same from the IsType() functions native in CF. For example,
IsArray(arguments) returns true, even though most array functions no
longer work on the arguments array in MX, IsSimpleValue(3) (which I
use for "string") and IsNumeric(3) will both return true. I believe
IsObject() and IsStruct() both return true for CFC's... So a
comprehensive function to get various types will depend a lot on what
kind of types your interested in and that will determine the order in
which the IsType() functions will need to be called.


if (isNumeric(v)) { return "numeric"; }
else if (isBoolean(v)) { return "boolean"; } // because 0 and 1 will
return true for this also
else if (isSimpleValue(v)) { return "string"; }
else if (isObject(v)) { return v.getClass().getClassName(); } // from
memory -- might be wrong
else if (isStruct(v)) { return "struct"; }
else if (isQuery(v)) { return "query"; }
else if (isArray(v)) { return "array"; }
else if (isBinary(v)) { return "binary"; }
else { return "unknown"; }

granted -- I left out XML, but you get the idea. The onTap version
also double-checks to make sure the CF version is recent enough to
support XML before testing since the xml functions may or may not
exist.


> You can always make a UDF for this. I'd check CFLib.org
> for one that may be
> there already.

> -----Original Message-----
> From: Adrian Lynch [mailto:[EMAIL PROTECTED]
> Sent: Friday, March 04, 2005 3:00 PM
> To: CF-Talk
> Subject: RE: Discover a variable's type?

> Well from a CF angle you have IsSimpleValue(),
> IsNumeric(), IsArray(),
> IsStruct(), IsObject() and IsQuery().

> Were you hoping for something along the lines of
> Type(yourVar)? There's
> bound to be a Java solution but whether it's simple or
> pretty, someone else
> will have to answer that one.

> Ade


s. isaac dealey   954.522.6080
new epoch : isn't it time for a change?

add features without fixtures with
the onTap open source framework

http://macromedia.breezecentral.com/p49777853/
http://www.sys-con.com/story/?storyid=48229&DE=1
http://www.sys-con.com/story/?storyid=44477&DE=1
http://www.sys-con.com/story/?storyid=45569&DE=1
http://www.sys-con.com/story/?storyid=48229&DE=1
http://www.fusiontap.com



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Find out how CFTicket can increase your company's customer support 
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:197524
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to