ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> incrtcl-users
incrtcl-users
Re: [Incrtcl-users] reference obj outside scope
by Brian Griffin other posts by this author
Aug 14 2006 9:34PM messages near this date
[Incrtcl-users] reference obj outside scope | [Incrtcl-users] Good doc for iTcl
Actually, objects are created based on the name.  You don't need to  
use the uplevel command to do this, just give the object a name in  
the scope you're interested in.  Have the method's return value be  
the object handle.

	package require Itcl

	itcl::class X {
		method announce {} {
			puts "Hello from $this"
		}
	}

	itcl::class Y {
		method make_an_X {name} {
			return [X $name]
		}
	}

	Y test
	test  make_an_X ::my_x

	::my_x announce

	test make_an_X ::#auto

	::x1 announce


-Brian

On Aug 14, 2006, at 3:55 PM, Prabhu Seshachellam wrote:

> 
>  Hi!
> 
>  Is it possible to instantiate a object of class X inside the method  
>  ABC of another class Y & keep that object active
>  so that i can reference it outside of method ABC  (i.e reference in  
>  another method) ?
> 
>  The "uplevel" command helps to solve this problem, by instantiating  
>  the object of class X in the caller's context.
>  But, i would like to have it in a global space so that any methods/ 
>  proc can reference it later.
> 
>  thanks
>  /prabhu
>  ---------------------------------------------------------------------- 
>  ---
>  Using Tomcat but need to do more? Need to support web services,  
>  security?
>  Get stuff done quickly with pre-integrated technology to make your  
>  job easier
>  Download IBM WebSphere Application Server v.1.0.1 based on Apache  
>  Geronimo
>  http://sel.as-us.falkag.net/sel? 
>  cmd=lnk&kid=120709&bid=263057&dat=121642______________________________ 
>  _________________
>  Incrtcl-users mailing list
>  Incrtcl-users@[...].net
>  https://lists.sourceforge.net/lists/listinfo/incrtcl-users


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Incrtcl-users mailing list
Incrtcl-users@[...].net
https://lists.sourceforge.net/lists/listinfo/incrtcl-users
Thread:
Prabhu Seshachellam
Brian Griffin

Privacy Policy | Email Opt-out | Feedback | Syndication
© 2004 ActiveState, a division of Sophos All rights reserved