Evaluate()'ing a Function with "Nothing" Returned
- December 28, 2007 10:34 AM
- ColdFusion
- Comments (0)
So, I'm plugging away at some cool image effect stuff, and I decided that it would be nice to wrap all my image functionality into an object, and that it would be cool to try CF8's new onMissingMethod function to implement the built in function set as methods of this new object. The overall effect would be really nifty and fun to use, but I hit a big old snag; the Evaluate() function fails with "nothing" returned.
I looked up some help on how to pull off this dynamic evaluation and found this article from Kinky Solutions that includes a method for dynamically calling functions based on the missing method call, but the Evaluate() function throws an error if the evaluated function returns "nothing". What functions return "nothing"? Well the CF8 Image functions return "nothing" according to the documentation, and apparently this is totally different then having no return value or void return.
Pop this into the old CF server and you get no errors.
<cfreturn />
</cffunction>
<cfset Evaluate("getVoid()") />
Or this, its ok too.
</cffunction>
<cfset Evaluate("getVoid()") />
Try this though, and everything goes wonky.
<cfset Evaluate("ImageSetDrawingColor(myImage, ""blue"")") />
But, switch it around to this, and things go ok:
<cfset Evaluate("ImageInfo(myImage)") />
Neat, huh?
Blarg.