Thanks Peter,

I hadn't even considered %ClassName() because for some reason I thought it didn't work in classmethods. Is this a new in Cach� 5, or did it always work and I just got it wrong?

Cheers
Billy


Peter Cooper wrote:

Billy

don't read the first bit - go to the second

Not easy you can look at $Stack special variablebut this is the COS routine
something like
MyPackage.MyClass.1
and you would have to hard code it to work out the full class name


other ways
a) pass a parameter
do ##class(class1).method1(..%ClassName(1))

b) set a % variable - these are process global

c) look at using polymorphism in method
so each calling class calls a "different" sub class of the method
class - each of these knows


=====================
Argh
just re-read your post
you do not need to do anything so complex

just use ..%ClassName(1)
this is the full name of the current class in the currently executing
context
So
##class(class1).method1()
..%ClassName(1)="package.class1"

##class(class2).method1()
..%ClassName(1)="package.class2"

also you can use class parameters to control different behaviour
eg
Class1
parameter SomeValue="here"
Class2
parameter SomeValue="there"

Inherited Method
write ..#SomeValue

will do "here" for class1
and "there" for class2

Peter


On Thu, 06 May 2004 11:14:51 +0200, Billy Young <[EMAIL PROTECTED]> wrote:


Hallo,

is there any way at runtime to determine through which class a classmethod has been called, without sending a parameter in?

e.g. I have 2 classes 'class1' and 'class2' which inherit the same class method 'method1'. If I run ##class(class1).method1() and ##class(class2).method1(), how can I tell at runtime inside method1 which class was specified in calling the classmethod?

Thanks
Billy






Reply via email to