Skip to main content

This is documentation for Caché & Ensemble. See the InterSystems IRIS version of this content.

For information on migrating to InterSystems IRIS, see Why Migrate to InterSystems IRIS?


Transfers program execution to the specified location.


Goto label


label A line label specifying the target of the Goto operation. A label is a valid identifier, followed by a colon suffix. See Labels in Using Caché Basic. The Goto label reference can be specified with or without a colon suffix.


The Goto statement immediately shifts program execution to the line location in the program specified by the label. The specified line must be in the same procedure as the Goto statement, or a compile-time error occurs.

The label argument specifies an existing label in the current program. Specifying the label's colon suffix is optional. Label names are case-sensitive. Specifying a non-existent label name results in a runtime error.


The following example illustrates the use of the Goto statement. Note that the label argument can include or omit the colon suffix:

  Println "Mod1"
  Goto Mod2
  Println "skipped over"
  Println "Mod2"
  Goto Mod4:
  Println "skipped Mod3"
  Println "Mod4"

The following example illustrates that more than one label can appear on a single line:

  Println "Mod1"
  Goto Mod3:
  Println "skipped over"
Mod2: Mod3:
  Println "Mods 2 and 3"
  Goto Mod4:
  Println "Mod4"

See Also

  • Basic: On Error Goto statement

  • ObjectScript: GOTO command

  • Labels in the “Lexical Structure” chapter of Using Caché Basic.