Written by

Senior Startups and Community Programs Manager at InterSystems Corporation
Question Evgeny Shvarov · Oct 2, 2022

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?

Comments

Dmitry Maslennikov · Oct 3, 2022

Why would you need it?

##class(class.name).#PARAMETER 

..#PARAMETER 

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

0
Evgeny Shvarov  Oct 3, 2022 to Dmitry Maslennikov

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.

0
Dmitry Maslennikov  Oct 3, 2022 to Evgeny Shvarov

The same code from comment below, but in Python

0
Alexander Koblov · Oct 3, 2022

%GetParameter:

SET myinst=##class(Sample.Person).%New()
WRITE myinst.%GetParameter("EXTENTQUERYSPEC")
0
Dmitry Maslennikov · Oct 3, 2022

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

0
Dmitry Maslennikov  Oct 3, 2022 to Dmitry Maslennikov

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%classnameSet%classname=%classQuit$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 .5Write !,"RunTime: ", ..#RUNTIME
  Quit1 }
zRUNTIMEP() public {
	Quit ($ZDateTime($ZTimeStamp,,,3)) }
0
Evgeny Shvarov  Oct 3, 2022 to Dmitry Maslennikov

Wow! Never knew of such an option!

0