The first error means that you aren't calling the method/routine correctly. See the <NOLINE> error code in this doc page: https://docs.intersystems.com/iris20231/csp/docbook/Doc.View.cls?KEY=RER... . Are you sure $$ConvertToMTime is the right name?

As for the second error: unlike most other programming languages, just calling a routine/method does not work in M/ObjectScript. Every line of code must use a command; in this case what you are looking for is the DO command: https://docs.intersystems.com/iris20231/csp/docbook/Doc.View.cls?KEY=RCO...

So, when calling a method/routine, you would write 'do ConvertToMTime(h,m,s)'

I'm not sure about TABLOCK specifically, but there are a couple other features that might help you solve this:

First, there is the LOCK TABLE statement: https://docs.intersystems.com/iris20241/csp/docbook/Doc.View.cls?KEY=RSQ...

There's also the objectscript LOCK command: https://docs.intersystems.com/iris20241/csp/docbook/Doc.View.cls?KEY=RCO...

You could use either of these to block the method while other instances of it are running and prevent the race condition. I'm not sure how efficient this method would be compared to TABLOCK, but it would fix the bug.

I hope this helps!

I'm not entirely clear on the question you are asking - if you just need to add quotes to a string, you can do so by escaping with another quotation mark. For example,

set b = """Cat""" // That's 3 quotation marks in a row on each side: one to open/close the string, two to add the quote character to the string

set c = b

w c
"Cat"

If you are asking how to display the quotes without actually adding quotes to the string, I'm not sure if that's possible - would need a more experienced dev to chime in.

I got an answer to this question internally and am reposting it here. From Daniel Bissex:

Using the MDX COUNT function is the slower of two options. We also have a provided Distinct plugin to address exactly this inefficiency:
https://docs.intersystems.com/iris20231/csp/documatic/%25CSP.Documatic.cls?LIBRARY=%25SYS&PRIVATE=1&CLASSNAME=%25DeepSee.PlugIn.Distinct

This uses our %KPI() function syntax, more detailed description of the calling options can be found here:
https://docs.intersystems.com/iris20231/csp/docbook/Doc.View.cls?KEY=D2RMDX_percentK

This reduced the runtime from ~5 minutes to about two seconds! The linked documentation is for IRIS 2023.1, but these functions are available in 2022.1 as well.