Written by

Senior Startups and Community Programs Manager at InterSystems Corporation
Article Evgeny Shvarov · Oct 15, 2022 1m read

Running ObjectScript classmethod in VSCode Terminal in One Click

Hi Devs!

For me, one of the most painful things about ObjectScript is ##class(Class).Method() typing to call a class method in code or in a terminal. I even submitted an idea to simplify it in ObjectScript.

But! There is a new feature in VSCode ObjectScript that was just introduced to the plugin - Copy Invocation!

Just hover Copy Invocation link above every classmethod in a code, click on it and the invocation is copied to the buffer:

Paste it anywhere you want it to execute!

USER>w ##class(dc.sample.ObjectScript).Test()

Bazinga!

Here is the video that shows how it works.

Many thanks to the VSCode contributors!

Happy coding!

Comments

Stephen Canzano · Oct 18, 2022

Nicely done.  while I haven't contributed to the project I do have a User Snippet

"Create Status Method": {
		  "prefix": "Method Create ClassMethod Returning %Status",
		  "body": [
			"///${1:Description}",
			"///<example>",
			"/// Set tSC=##class($TM_FILENAME_BASE).${2:MethodName}()",
			"///</example>",
			"ClassMethod ${2:MethodName}(${3:parameters}) As %Status",
			" {",
			"  #dim tSC \t\t\t As %Status=\\$\\$\\$OK",
			"  #dim eException \t As %Exception.AbstractException",
			"  try {",
			"   $0",
			"  }",
			"  catch eException {",
			"   Set tSC=eException.AsStatus()",
			"  }",
			" Quit tSC",
			" }"
		  ],
		  "description": "Method Create ClassMethod Returning %Status"
		}

that utilizes the <example> Documatic special tag as I too was tired typing the ##class when testing methods.  My approach is different and it's not perfect but it works for me.  It also produces a class method with a consistent pattern/structure.

0
Marcelo Witt · Nov 29, 2022

Nice! And when there are parameters, how does it works?

0
Evgeny Shvarov  Nov 30, 2022 to Marcelo Witt

No magic here) BYOP - which means bring your own parameters)

0
Irène Mykhailova · Dec 19, 2022

This is why I like Studio, right click and you're good to go :)

0
Dmitry Maslennikov  Dec 20, 2022 to Irène Mykhailova

What do you mean, what do you have by right click?

0
Evgeny Shvarov  Apr 26, 2023 to Irène Mykhailova

You mean you like Visual Studio Code? )

0