IsLabel()

Returns a non-zero number if the specified label exists in the script.

Boolean := IsLabel(LabelName)

Parameters

LabelName

The name of a subroutine, hotkey, or hotstring. The trailing colon(s) should not be included.

Return Value

This function returns 1 (true) if LabelName exists in the script, otherwise 0 (false).

Remarks

This function is useful to avoid runtime errors when specifying a dynamic label in commands such as Gosub, Hotkey, Menu, and Gui.

Labels

Examples

Reports "Subroutine exists" because the subroutine does exist.

if IsLabel("Label")
    MsgBox, Subroutine exists
else
    MsgBox, Subroutine doesn't exist

Label:
return

Reports "Hotkey exists" because the hotkey does exist.

if IsLabel("^#h")
    MsgBox, Hotkey exists
else
    MsgBox, Hotkey doesn't exist

^#h::return

Reports "Hotstring exists" because the hotstring does exist.

if IsLabel("::btw")
    MsgBox, Hotstring exists
else
    MsgBox, Hotstring doesn't exist

::btw::by the way