Caché Basic Reference
Goto
[Back] [Next]
   
Server:docs1
Instance:LATEST
User:UnknownUser
 
-
Go to:
Search:    

Transfers program execution to the specified location.
Synopsis
Goto label
Arguments
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.
Description
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.
Examples
The following example illustrates the use of the Goto statement. Note that the label argument can include or omit the colon suffix:
Mod1:
  Println "Mod1"
  Goto Mod2
  Println "skipped over"
Mod2:
  Println "Mod2"
  Goto Mod4:
Mod3:
  Println "skipped Mod3"
Mod4:
  Println "Mod4"
 
The following example illustrates that more than one label can appear on a single line:
Mod1:
  Println "Mod1"
  Goto Mod3:
  Println "skipped over"
Mod2: Mod3:
  Println "Mods 2 and 3"
  Goto Mod4:
Mod4:
  Println "Mod4"
 
See Also