Transfering control to another lineΒΆ

goto

Transfer control to another line


SYNTAX

goto label

The goto command transfers program control to the statement at the label indicated.

Beware of jumping in or out of subroutines. The program will compile, but is unlikely to work as intended.

Heavy use of the goto command is not recommended because of its extreme inelegance; it tends to lead to unstructured code, which is difficult to follow and to debug.


EXAMPLE

!function ReformatRenameFiles() {
!temp ErrMsg,,a50

     ErrMsg = ""

     TempDDPath = CurrentDirSlash /  RFTempName / ".d"
     if (copyfile(TempDDPath, FullDDPath, COPY_TEXT) <> 1) {
          ErrMsg = "Error copying data dictionary"
          goto RRF_ERROR
     }
     ...

     RenameDone = TRUE
     return OKAY

RRF_ERROR:
     error tostr(ErrMsg), \
          "Operating system error " + tostr(sys.Errno)
     return ERROR
}

RELATED TOPICS

gosub