Whatever message this page gives is out now! Go check it out!
GetFunctionCalledName() |
//callednamedemo.cfc
component
{
variables.x1 = 1;
variables.y1 = 2;
function init()
{
return this;
}
function get()
{
var name = getFunctionCalledName();
return variables[mid(name,4,len(name)-3)];
}
function set(value)
{
var name = getFunctionCalledName();
variables[mid(name,4,len(name)-3)] = value;
}
this.getX1 = get;
this.getY1 = get;
this.setX1 = set;
this.setY1 = set;
}
<!--- calledname.cfm --->
<cfscript>
function test()
{
return getFunctionCalledName();
}
WriteOutput(test() & "<br>"); // test
a = test;
WriteOutput(variables.a() & "<br>"); // a
o = new callednamedemo();
// shows *real* methods get(), SetX1() and getY1(), etc.
writeDump(o);
o.setX1(10);
o.setY1(20);
WriteOutput(o.getX1() & "<br>"); // 10
WriteOutput(o.getY1() & "<br>") ; // 20 </cfscript>