Using CFC's
Hello,
I have a simple CFC defined as such. And named ct.cfc
<cfcomponent>
<!--- Celsius to Fahrenheit conversion method. --->
<cffunction name="ctof" output="false">
<cfargument name="temp" required="yes" type="numeric">
<cfreturn ((temp*9)/5)+32>
</cffunction>
</cfcomponent>
Then I have a .cfm file named test.cfm and both the cfc file and the cfm file are in the same directory. The test.cfm file is below:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
</head>
<body>
<cfscript>
obj1 = createObject("component","ct");
obj1.ctof(temp=100);
</cfscript>
</body>
</html>
I can't seem to figure out how to print the output of obj1 to the screen. I have tried obj1.temp and that does not work. Also all of the code above does not throw an error. It is only when I try to cfoutput the value I run into problems. So how do you print the value? It should be 212.
Thanks,
Jim