No registered users in community xowiki
in last 10 minutes
in last 10 minutes
Re: [Xotcl] proper way to access xotcl classes
From: Gustaf Neumann <neumann_at_wu-wien.ac.at>
Date: Wed, 07 May 2008 22:38:40 +0200
Matthew Smith schrieb:
>
> How do I call the methods like push and pop?
Let us assume, you have a class "Stack" defined and
the class stack contains definitions for the methods
(instprocs) "push" and "pop". The class provides these
methods for ins instances. Therefore, in order to
invoke these methods, you will need an instance
of class Stack (an object of the type Stack). One can
create such an instances (e.g. "s1") with the following
command
Stack s1
Once the object exists, the methods "push" and "pop" can be called via
s1 push a
or
puts [s1 pop]
So, the first word of the Tcl command refers to the object
(the instance of class stack) and the second word refers to the method.
If there are more words, these are passed as arguments to the method.
Hope, this helps
-gustaf neumann
PS: The xotcl-core tutorial ist for the OpenACS environment.
There, it is not necessary to include the "package require XOTcl"
and the "namespace import ::xotcl::*". You need these
commands in case you use XOTcl in a tclsh.
Date: Wed, 07 May 2008 22:38:40 +0200
Matthew Smith schrieb:
>
> How do I call the methods like push and pop?
Let us assume, you have a class "Stack" defined and
the class stack contains definitions for the methods
(instprocs) "push" and "pop". The class provides these
methods for ins instances. Therefore, in order to
invoke these methods, you will need an instance
of class Stack (an object of the type Stack). One can
create such an instances (e.g. "s1") with the following
command
Stack s1
Once the object exists, the methods "push" and "pop" can be called via
s1 push a
or
puts [s1 pop]
So, the first word of the Tcl command refers to the object
(the instance of class stack) and the second word refers to the method.
If there are more words, these are passed as arguments to the method.
Hope, this helps
-gustaf neumann
PS: The xotcl-core tutorial ist for the OpenACS environment.
There, it is not necessary to include the "package require XOTcl"
and the "namespace import ::xotcl::*". You need these
commands in case you use XOTcl in a tclsh.