View · Search · Index
No registered users in community xowiki
in last 10 minutes

Re: [Xotcl] proper way to access xotcl classes

From: Kristoffer Lawson <setok_at_scred.com>
Date: Wed, 7 May 2008 21:01:36 +0300

On 7 May 2008, at 20:54, Matthew Smith wrote:

>
> ---------------------------------------------------------
> How do I access the class methods(i guess they are called) from within
> the tcl file?
> The examples show this:
> --------------------------------------------------------
> # Create Object s1 of class Stack
> % Stack s1
> ::s1
> % s1 push a
> a
> % s1 push b
> b
> % s1 push c
> c
> % s1 pop
> c
> % s1 pop
> b
> # Delete object s1
> s1 destroy
> --------------------------------------------------------
> I have tried this:
> set s1 [Stack]
>

Either this:

set s1 [Stack new]

or

set s1 [Stack s1]

The first version gives you an automatically named object, which is
probably what you usually want to do. You can also explicitly name
objects with the latter version (something you cannot do with Java
and stuff). Mostly you wont need to do this, but there are situations
when it's useful.

            / http://www.scred.com/
            / http://www.fishpool.com/~setok/