Access to OnInit properties?

The OnInit(initData) function in a user command script defines name, version, desc, etc.. Is there a way of accessing these static initData properties when the user command is run? I am currently setting a local variable for version during OnInit and retrieving it via Script.vars("version") at run time. I may have missed a simpler approach.

Those properties are provided by your script, so presumably it already knows them?

Yes it does, but let's say that in OnInit I define..

initData.version = "1.0 (January 8th, 2019)";

then in the body of the script code I'd like to be able to access this constant information by reference rather than having to re-specify the string. e.g.

DOpus.output("Version = " + initData.version)
vs
DOpus.output("Version = 1.0 (January 8th, 2019)")

However, the initData object is not available when the user command is run so I set a script level variable during OnInit which I can retrieve at run time. I'm just wondering if I have missed an easier, more elegant way?

I don't disagree, however you could make a global variable (a js var not a dopus var) and then use it in both places.

var version = "1.0 (January 8th, 2019)";
initData.version = version ;
DOpus.output("Version = " + version)
1 Like

Good suggestion. That makes sense to me.