Question
Evgeny Shvarov · Oct 2

Are there auto-generated getter methods for class parameters in ObjectScript?

Hi, ObjectScript experts!

I know that there are auto-generated getter and setter methods for class properties in ObjectScript.

Are there auto-generated getter methods for class parameters?

0
0 91
Discussion (7)2
Log in or sign up to continue

Why would you need it?

##class(class.name).#PARAMETER 

..#PARAMETER 

$parameter(“class.name”, “PARAMETER”)

This is to refer to a parameter via Embedded Python.

I’m rewriting the ObjectScript code to Embedded python and looking for the options how to deal with class parameters. Just don’t want to introduce a helper ObjectScript method to get the parameter value.

Thought it could be something autogenerated as it is for properties.

%GetParameter:

SET myinst=##class(Sample.Person).%New()
WRITE myinst.%GetParameter("EXTENTQUERYSPEC")

By default the value of the parameter is static. But you can define parameters that way that the value can be evaluated at RunTime or CompileTime

So, technically, you can define the Get method for Parameters

And generated code for those parameters

ROUTINE User.Test.G1 [Type=INT,Generated]
	;User.Test.G1
	;(C)InterSystems, method generator for class User.Test.  Do NOT edit.
	Quit
	;
pCOMPILETIME(%class,%parameter) public { New %classname Set %classname=%class
 Quit $ZDateTime($ZTimeStamp,,,3)
}
ROUTINE User.Test.1 [Type=INT,Generated]
 ;User.Test.1
 ;Generated for class User.Test.  Do NOT edit. 10/03/2022 07:50:07AM
 ;;3043524C;User.Test
 ;
ztest() public {
  Write !,"RunTime: ", ..#RUNTIME
  Write !,"CompileTime: ", ..#COMPILETIME
  hang .5
  Write !,"RunTime: ", ..#RUNTIME
  Quit 1 }
zRUNTIMEP() public {
	Quit ($ZDateTime($ZTimeStamp,,,3)) }