Given:
And knowing that in caché Object Script:
How should I call classMethod foo if I want to pass the property "intA" byRef? Because preceding the property name with 3 dots seems to be not the correct way.
Code Snippet class B:
Class B Extends %RegisteredObject
{
///doubles num
ClassMethod foo(ByRef num As %Integer)
{
set num = num*2
}
}
Code Snippet class A:
Class A Extends %RegisteredObject
{
Property intA As %Integer;
Method test()
{
set ..intA= 5
do ##class(B).foo(..intA)
//If correctly passed by ref, ..intA should be 10, but it is still 5
}
}
Thanks in advance.
Only variables local or global, could be passed by reference. For properties it is not possible. You can pass property name as a string, and set value with $property method. And if you need to do it in class method or/and in other class, you should pass variable this as well. So your code could go a little something like this:
ClassMethod foo(this, propName As %String)
{
set $property(this, propName)=$property(this, propName) * 2
}
Method test()
{
set ..intA=5
do ##class(b).foo(%this, "intA")
}