Skip to main content

What’s That?

As you read existing ObjectScript code, you may encounter unfamiliar syntax forms. This page shows syntax forms in different groups, and it explains what they are and where to find more information.

This page does not list single characters that are obviously operators or that are obviously arguments to functions or commands.

Non-Alphanumeric Characters in the Middle of “Words”

This section lists forms that look like words with non-alphanumeric characters in them. Many of these are obvious, because the operators are familiar. For example:

x>5

The less obvious forms are these:

abc^def

def is a routine, and abc is a label within that routine. abc^def is a subroutine.

Variation for abc:

  • %abc

Some variations for def:

  • %def

  • def.ghi

  • %def.ghi

  • def(xxx)

  • %def(xxx)

  • def.ghi(xxx)

  • %def.ghi(xxx)

xxx is an optional, comma-separated list of arguments.

A label can start with a percent sign but is purely alphanumeric after that.

A routine name can start with a percent sign and can include one or more periods. The caret is not part of its name. (In casual usage, however, it is very common to refer to a routine as if its name included an initial caret. Thus you may see comments about the ^def routine. Usually you can tell from context whether the reference is to a global or to a routine.)

i%abcdef

This is an instance variable, which you can use to get or to set the value of the abcdef property of an object. See Object-specific ObjectScript Features.

This syntax can be used only in an instance method. abcdef is a property in the same class or in a superclass.

abc->def

Variations:

  • abc->def->ghi and so on

This syntax is possible only within InterSystems SQL statements. It is an example of InterSystems IRIS arrow syntax and it specifies an implicit left outer join. abc is an object-valued field in the class that you are querying, and def is a field in the child class.

abc->def is analogous to dot syntax (abc.def), which you cannot use in InterSystems SQL.

For information on InterSystems IRIS arrow syntax, see Implicit Joins (Arrow Syntax).

abc?def

Variation:

  • "abc"?def

A question mark is the pattern match operator. In the first form, this expression tests whether the value in the variable abc matches the pattern specified in def. In the second form, "abc" is a string literal that is being tested.

Note that both the string literal "abc" and the argument def can include characters other than letters.

"abc"["def"

Variations:

  • abc[def

  • abc["def"

  • "abc"[def

A left bracket ([) is the binary contains operator. In the first form, this expression tests whether the string literal "abc" contains the string literal "def". In later forms, abc and def are variables that are being tested.

Note that both the string literals "abc" and "def" can include characters other than letters.

"abc"]"def"

Variations:

  • abc]def

  • abc]"def"

  • "abc"]def

A right bracket (]) is the binary follows operator. In the first form, this expression tests whether the string literal "abc" comes after the string literal "def", in ASCII collating sequence. In later forms, abc and def are variables that are being tested.

Note that both the string literals "abc" and "def" can include characters other than letters.

"abc"]]"def"

Variations:

  • abc]]def

  • abc]]"def"

  • "abc"]]def

Two right brackets together (]]) are the binary sorts after operator. In the first form, this expression tests whether the string literal "abc" sorts after the string literal "def", in numeric subscript collation sequence. In later forms, abc and def are variables that are being tested.

Note that both the string literals "abc" and "def" can include characters other than letters.

. (One Period)

period within an argument list

Variations:

  • abc.def(.ghi)

  • abc(.xyz)

When you call a method or routine, you can pass an argument by reference or as output. To do so, place a period before the argument.

period at the start of a line

An older form of the Do command uses a period prefix to group lines of code together into a code block. This older Do command is not for use with InterSystems IRIS.

.. (Two Periods)

In every case, two periods together are the start of a reference from within a class member to another class member.

..abcdef

This syntax can be used only in an instance method (not in routines or class methods). abcdef is a property in the same class.

..abcdef(xxx)

This syntax can be used only in a method (not in routines). abcdef() is another method in the same class, and xxx is an optional comma-separated list of arguments.

..#abcdef

This syntax can be used only in a method (not in routines). abcdef is a parameter in this class.

In classes provided by InterSystems, all parameters are defined in all capitals, by convention, but your code is not required to do this.

Remember that the pound sign is not part of the parameter name.

... (Three Periods)

In the argument list of a method or a procedure, the last argument can be followed by three periods.

abcdef...

abcdef is an argument of the method or procedure and typically has a generic name such as arguments. The three periods indicate that additional arguments are accepted at this position in the argument list. See Specifying a Variable Number of Arguments and Variable Number of Parameters. When calling the method or procedure, do not include the three periods; simply include the arguments as needed, in the order needed, at this position in the argument list.

# (Pound Sign)

This section lists forms that start with a pound sign.

#abcdef

In most cases, #abcdef is a preprocessor directive. InterSystems IRIS provides a set of preprocessor directives. Their names start with either one or two pound signs. Here are some common examples:

  • #define defines a macro (possibly with arguments)

  • #def1arg defines a macro that has one argument that includes commas

  • #sqlcompile mode specifies the compilation mode for any subsequent embedded SQL statements

For reference information and other directives, see ObjectScript Macros and the Macro Preprocessor.

Less commonly, the form #abcdef is an argument used with specific commands (such as READ and WRITE), special variables, or routines. For details, consult the reference information for the command, variable, or routine that uses this argument.

##abcdef

##abcdef is a preprocessor directive. See the comments for #abcdef.

##class(abc.def).ghi(xxx)

Variation:

  • ##class(def).ghi(xxx)

abc.def is a package and class name, ghi is a class method in that class, and xxx is an optional comma-separated list of arguments.

If the package is omitted, the class def is in the same package as the class that contains this reference.

##super()

Variations:

  • ##super(abcdef)

This syntax can be used only in a method. It invokes the overridden method of the superclass, from within the current method of the same name in the current class. abcdef is a comma-separated list of arguments for the method. See Object-specific ObjectScript Features in Defining and Using Classes.

Dollar Sign ($)

This section lists forms that start with a dollar sign.

$abcdef

Usually, $abcdef is a special variable. See ObjectScript Special Variables in the ObjectScript Reference.

$abcdef could also be a custom special variable. See Extending ObjectScript with %ZLang.

$abcdef(xxx)

Usually, $abcdef() is a system function, and xxx is an optional comma-separated list of arguments. For reference information, see the ObjectScript Reference.

$abcdef() could also be a custom function. See Extending ObjectScript with %ZLang.

$abc.def.ghi(xxx)

In this form, $abc is $SYSTEM (in any case), def is the name of class in the %SYSTEM package, ghi is the name of a method in that class, and xxx is an optional comma-separated list of arguments for that method.

The $SYSTEM special variable is an alias for the %SYSTEM package, to provide language-independent access to methods in classes of that package. For example: $SYSTEM.SQL.DATEDIFF

For information on the methods in this class, see the InterSystems Class Reference.

$$abc

Variation:

  • $$abc(xxx)

abc is a subroutine defined within the routine or the method that contains this reference. This syntax invokes the subroutine abc and gets its return value. See User-defined Code in Using ObjectScript.

$$abc^def

Variations:

  • $$abc^def(xxx)

  • $$abc^def.ghi

  • $$abc^def.ghi(xxx)

This syntax invokes the subroutine abc and gets its return value. The part after the caret is the name of the routine that contains this subroutine. See User-defined Code in Using ObjectScript.

$$$abcdef

abcdef is a macro; note that the dollar signs are not part of its name (and are thus not seen in the macro definition).

Some of the macros supplied by InterSystems IRIS are documented in System-Supplied Macro Reference.

In casual usage, it is common to refer to a macro as if its name included the dollar signs. Thus you may see comments about the $$$abcdef macro.

Percent Sign (%)

By convention, most packages, classes, and methods in InterSystems IRIS system classes start with a percent character. From the context, it should be clear whether the element you are examining is one of these. Otherwise, the possibilities are as follows:

%abcdef

%abcdef is one of the following:

  • A local variable, including possibly a local variable set by InterSystems IRIS.

  • A routine.

    Variation:

    • %abcdef.ghijkl

  • An embedded SQL variable (these are %msg, %ok, %ROWCOUNT, and %ROWID).

    For information, see System Variables.

  • An InterSystems SQL command, function, or predicate condition (for example, %STARTSWITH and %SQLUPPER).

    Variation:

    • %abcdef(xxx)

    For information, see the InterSystems SQL Reference.

%%abcdef

%abcdef is %%CLASSNAME, %%CLASSNAMEQ, %%ID, or %%TABLENAME. These are pseudo-field keywords. For details, see the InterSystems SQL Reference.

Caret (^)

This section lists forms that start with a caret, from more common to less common.

^abcdef

Variation:

  • ^%abcdef

There are three possibilities:

  • ^abcdef or ^%abcdef is a global.

  • ^abcdef or ^%abcdef is an argument of the LOCK command. In this case, ^abcdef or ^%abcdef is a lock name and is held in the lock table (in memory).

  • abcdef or %abcdef is a routine. The caret is not part of the name, but rather part of the syntax to call the routine.

In casual usage, it is very common to refer to a routine as if its name included an initial caret. Thus you may see comments about the ^abcdef routine. Usually you can tell from context whether the reference is to a global or to a routine. Lock names appear only after the LOCK command; they cannot be used in any other context.

^$abcdef

Variation:

  • ^$|"ghijkl"|abcdef

Each of these is a structured system variable, which provides information about globals, jobs, locks, or routines.

$abcdef is $GLOBAL, $JOB, $LOCK, or $ROUTINE.

ghijkl is a namespace name.

InterSystems IRIS stores information in the following system variables:

See the ObjectScript Reference.

^||abcdef

Variations:

  • ^|"^"|abcdef

  • ^["^"]abcdef

  • ^["^",""]abcdef

Each of these is a process-private global, a mechanism for temporary storage of large data values. InterSystems IRIS uses some internally but does not present any for public use. You can define and use your own process-private globals. See Variables.

^|XXX|abcdef

Some variations:

  • ^|XXX|%abcdef

  • ^[XXX]abcdef

  • ^[XXX]%abcdef

Each of these is an extended reference — a reference to a global or a routine in another namespace. The possibilities are as follows:

  • ^abcdef or ^%abcdef is a global in the other namespace.

  • abcdef or %abcdef is a routine in the other namespace.

The XXX component indicates the namespace. This is either a quoted string or an unquoted string. See “Extended References” in Syntax Rules.

^abc^def

This is an implied namespace. See ZNSPACE in the ObjectScript Reference.

^^abcdef

This is an implied namespace. See the ZNSPACE entry in the ObjectScript Reference.

Other Forms

+abcdef

Some variations:

  • +^abcdef

  • +"abcdef"

Each of these expressions returns a number. In the first version, abcdef is the name of a local variable. If the contents of this variable do not start with a numeric character, the expression returns 0. If the contents do start with a numeric character, the expression returns that numeric character and all numeric characters after it, until the first nonnumeric character. For a demonstration, run the following example:

 write +"123abc456"

See String Relational Operators.

{"abc":(def),"abc":(def),"abc":(def)}

This syntax is a JSON object literal and it returns an instance of %DynamicObjectOpens in a new tab. "abc" is the name of a property, and def is the value of the property. For details, see Using JSON.

{abcdef}

This syntax is possible where InterSystems SQL uses ObjectScript. abcdef is the name of a field. See Referring to Fields from ObjectScript in Defining and Using Classes.

{%%CLASSNAME}

This syntax can be used within trigger code and is replaced at class compilation time.

Others:

  • {%%CLASSNAMEQ}

  • {%%ID}

  • {%%TABLENAME}

These items are not case-sensitive. See CREATE TRIGGER in the InterSystems SQL Reference.

&sql(xxx)

This is embedded SQL and can be used anywhere ObjectScript is used. xxx is one SQL statement. See Using Embedded SQL.

[abcdef,abcdef,abcdef]

This syntax is a JSON array literal and it returns an instance of %DynamicArrayOpens in a new tab. abcdef is an item in the array. For details, see Using JSON.

*abcdef

Special syntax used by the following functions and commands:

See these items in the ObjectScript Reference.

?abcdef

The question mark is the pattern match operator and abcdef is the comparison pattern.

@abcdef

The at sign is the indirection operator.

See Also

FeedbackOpens in a new tab