Article
· 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!

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

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.