VBAjedi
|
Posted: 10/16/2003, 2:40 PM |
|
I don't understand the way CCS uses the $Tpl variable. Can you somehow declare an object variable, and then start referencing its methods before you even assign anything to the variable? CCS declares $Tpl as a global inside a function (which is in turn inside a class), and then immediately starts referencing various $Tpl methods and functions. For example:
function Show($Name)
{
global $Tpl;
$block_path = $Tpl->block_path;
I can't see what $Tpl itself is being set to. Unless the global keyword means it is inheriting the classes definition (which assigns a null string as the default value):
var $Tpl = "";
But that still doesn't answer my question - how does the code know what kind of object $Tpl is?
|
|
|
VBAjedi
|
Posted: 10/16/2003, 3:13 PM |
|
Ok, it hadn't occurred to me that $Tpl might be a special reserved CCS variable, but I just found out in the help files that it is. Doh!
My question now is much simpler: what is gained by declaring it as a global inside a function?
|
|
|
RonB
|
Posted: 10/17/2003, 12:07 AM |
|
By declaring it global inside the function you make sure that when the function is acalled before $Tpl has been declared global you still cab acces the $Tpl object. I think all it does is put $Tpl in scope.
You do the same thing when you ad an event to a page. You first declare the grid/connection or template object global therefore getting acces to all functions etc that belong to that object. The event itself is also a function.
Ron
|
|
|
VBAjedi
|
Posted: 10/17/2003, 11:51 AM |
|
Thanks, Ron! Stuff is starting to make more sense. . . good thing, too, cause I don't think my monitor screen could hold up to too much more head-pounding!
LOL
VBAjedi
|
|
|
|