Class Methods and Routines
To run class methods, you use Do and the ##class syntax. If the class method you're calling is in the same class, you can use the .. shortcut (called relative dot syntax), which is similar to this. syntax for class methods in other languages. If a class method returns a value, you can use it anywhere an expression is allowed. The most typical case is using Set to assign the result of a class method to a variable.
USER>set cpus = ##class(%SYSTEM.Util).NumberOfCPUs()
InterSystems IRIS class methods belonging to % classes (classes that start with the % character) can be called from any namespace. Class names and method names are case-sensitive.
Here's a summary of the several syntaxes you've seen for running code, calling either class methods or system routines. What's the difference between class methods and routines? Routines (and procedures within them) are an older form, still supported for backwards compatibility. This tutorial focuses on class methods; note that most of what is taught about class methods also applies to routines and procedures. You can use VS Code - ObjectScript to create routines also.
Calling Class Methods
||Call the Main() class method of the ObjectScript.RightTriangle class.
||Call the IsNegative() class method of the current class (ObjectScript.RightTriangle) to decide whether or not to stop looping.
|do ..Compute(units, side1, side2)
||Call the Compute() class method of the current class (ObjectScript.RightTriangle) to do the computations.
|set cpus = ##class(%SYSTEM.Util).NumberOfCPUs()
||Call the NumberOfCPUs() class method of the %SYSTEM.UtilOpens in a new tab class, and assign its return value to a variable.
||Call the %D routine to display the current date.
||Call the %T routine to display the current time.
||Call the %CD routine to change to another namespace.
||Call the %FREECNT routine to display the available space in the current database.
||Call the ALL procedure within the %FREECNT routine to display the available space in ALL databases.