Hi Staff
I wanted to start using JMP classes in scripting, but ran into an unfortunate behaviour: When giving arguments to a method, the arguments are treated as if they were class members, which makes classes almost unusable as the argument to the method depends on if a class member already uses that variable. I found no way to force sending a global or here: variable to the method. I believe it to be a bug. The following code reproduces this behaviour:
define class ("aClass",
varA = .;
aMethod=method({someVar},
varA = someVar;
show(someVar);
)
);
obj=new object(aClass());
varB=3;
obj:aMethod(varB);
varA=4;
obj:aMethod(varA);
obj:aMethod(::varA);
In the above, because varA is both a global variable and a metod variable, "aMethod" just gets 3 and not 4 in the argument. So behaviour is influenced by interaction between internal class member names and global variable names.
Kind regards,
Thomas
I agree, it does look like a bug. @EvanMcCorkle @audrey_shull
A workaround is to prefix the member variable names with m_ . I've used that prefix, or a variation, for a long time to help anyone reading the code understand when they are looking at a member variable.
And a couple of posts using classes:
How to use Define Class
Functional programming using JSL objects