Xbasic

GOTO

Syntax

GOTO Label_Name

Arguments

Label_Name

A label within the script. The label must be terminated with a colon ":".

Description

Causes the execution of a script to skip to the line after the specified label.

A label definition can be anywhere within a script; however, the GOTO command cannot reference a label outside the script in which it is contained.

Example 

This script searches for a customer whose last name is 'Smith'. 'If Smith is found, execution will skip to the name_found label.

tbl = table.current()
search_name = "Smith"
tbl.fetch_first()
while .not. tbl.fetch_eof()
    if trim(tbl.last_name) = search_name then
        goto name_found
    end if
    tbl.fetch_next()
end while
ui_msg_box("Search", "Not Found.")
end
name_found:
    ui_msg_box("Search", search_name + " has been found.")
end

See Also