Skip to content

API UO SubExists en

Codex edited this page Oct 3, 2026 · 1 revision

UO.SubExists

Русский · English · Українська · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어

UO.CallSub · UO.FunRunning · UO.SubExists

ClassicUO • Runtime API

Checks for a procedure definition in the manager's current catalogue. Useful before launching an optional module; existence does not imply execution or eligibility for a zero-argument launch.

Exact syntax

UO.SubExists(subrutineName:String) -> Integer

Parameters

  • subrutineName — Required String subrutineName is the catalogue's Sub/Function name, such as WeightWatch. Not a path, file name, run index, source text or label changed with SetScriptName. Matching ignores case but does not trim spaces. This call cannot pass procedure arguments.

Returns

Integer: 1 (True) when a definition is found; 0 (False) otherwise. If UO.SubExists(name), = 1 and = True are valid; 0 corresponds to False. This does not check a disk file, validity or an active execution.

Behavior

  • Only this session's catalogue is searched. Duplicate names select the first match: give independent procedures unique names. These three commands neither load an unknown file nor search the disk.
  • CallSub supplies zero arguments. Private access, syntax errors, required parameters, disabled Basic or the single-procedure rule can reject the launch; inspect IDE status/errors. Calling an active procedure again neither duplicates nor resumes it. A start after cancellation may wait for prior cleanup. The controller's next statement does not wait for completion.
  • FunRunning resolves the source procedure name/key, not a renamed display label. Pausing retains the run and returns 1. Cancellation returns 0 even while cleanup continues. A check and a subsequent call are not atomic: the task can finish between them.
  • SubExists can return 1 for a Private or invalid definition: existence is not launch permission. Stopping a run or closing its editor tab does not necessarily remove its catalogue entry. Reloading a changed file removes obsolete definitions. A function loaded only into a separate runtime need not be registered with the manager.

Internal functions: from call to result

These are real implementation stages; their C# names are not additional UO commands. All executable Basic helpers are fully defined in the examples.

1. SubExists

Required String subrutineName is the catalogue's Sub/Function name, such as WeightWatch. Not a path, file name, run index, source text or label changed with SetScriptName. Matching ignores case but does not trim spaces. This call cannot pass procedure arguments.

Integer: 1 (True) when a definition is found; 0 (False) otherwise. If UO.SubExists(name), = 1 and = True are valid; 0 corresponds to False. This does not check a disk file, validity or an active execution.

Project source: external/InjectionScript/src/InjectionScript/Runtime/InjectionApiUO.cs; function SubExists.

2. FindProcedureByName

Only this session's catalogue is searched. Duplicate names select the first match: give independent procedures unique names. These three commands neither load an unknown file nor search the disk.

SubExists can return 1 for a Private or invalid definition: existence is not launch permission. Stopping a run or closing its editor tab does not necessarily remove its catalogue entry. Reloading a changed file removes obsolete definitions. A function loaded only into a separate runtime need not be registered with the manager.

Project source: src/ClassicUO.Client/Game/Managers/YokoInjectionManager.cs; function FindProcedureByName.

3. SubExists

Checks for a procedure definition in the manager's current catalogue. Useful before launching an optional module; existence does not imply execution or eligibility for a zero-argument launch.

SubExists can return 1 for a Private or invalid definition: existence is not launch permission. Stopping a run or closing its editor tab does not necessarily remove its catalogue entry. Reloading a changed file removes obsolete definitions. A function loaded only into a separate runtime need not be registered with the manager.

Project source: src/ClassicUO.Client/Game/Managers/ClassicUOInjectionApiBridge.cs; function SubExists.

These are real implementation stages; their C# names are not additional UO commands. All executable Basic helpers are fully defined in the examples.

Examples

Launch an available optional procedure

# Launch an available optional procedure
#
# Checks for a procedure definition in the manager's current catalogue. Useful before launching
# an optional module; existence does not imply execution or eligibility for a zero-argument
# launch.
#
# Integer: 1 (True) when a definition is found; 0 (False) otherwise. If UO.SubExists(name), = 1
# and = True are valid; 0 corresponds to False. This does not check a disk file, validity or an
# active execution.

SUB Main()
    # For this Boolean result, = True is equivalent to = 1. The WeightWatch definition below must be
    # registered by loading the file.
    # Save each example as a separate file, load it in the IDE/manager and start Main so the other
    # procedures are registered. WeightWatch/ManaWatch are fully defined teaching helpers: three
    # weight/mana samples, Wait(1000) meaning 1000 ms, output only while in the world. They are
    # finite monitors; pauses can extend elapsed time. The two-task example requires concurrent
    # procedures to be enabled.

    If UO.SubExists("WeightWatch") = True Then
        UO.CallSub("WeightWatch")
    End If
END SUB

Sub WeightWatch()
    Dim sample
    For sample = 1 To 3
        If UO.Connected() Then
            UO.Print("Weight: " & CStr(UO.Weight()))
        End If
        UO.Wait(1000)
    Next
End Sub

Parameter and execution notes:

  • For this Boolean result, = True is equivalent to = 1. The WeightWatch definition below must be registered by loading the file.
  • Save each example as a separate file, load it in the IDE/manager and start Main so the other procedures are registered. WeightWatch/ManaWatch are fully defined teaching helpers: three weight/mana samples, Wait(1000) meaning 1000 ms, output only while in the world. They are finite monitors; pauses can extend elapsed time. The two-task example requires concurrent procedures to be enabled.

Choose a fallback handler

# Choose a fallback handler
#
# Checks for a procedure definition in the manager's current catalogue. Useful before launching
# an optional module; existence does not imply execution or eligibility for a zero-argument
# launch.
#
# Integer: 1 (True) when a definition is found; 0 (False) otherwise. If UO.SubExists(name), = 1
# and = True are valid; 0 corresponds to False. This does not check a disk file, validity or an
# active execution.

SUB Main()
    # WeightWatch may come from another loaded file. When absent, the local ManaWatch is chosen.
    # Finding a primary that cannot launch does not automatically choose the fallback.
    # Save each example as a separate file, load it in the IDE/manager and start Main so the other
    # procedures are registered. WeightWatch/ManaWatch are fully defined teaching helpers: three
    # weight/mana samples, Wait(1000) meaning 1000 ms, output only while in the world. They are
    # finite monitors; pauses can extend elapsed time. The two-task example requires concurrent
    # procedures to be enabled.

    If UO.SubExists("WeightWatch") = 1 Then
        UO.CallSub("WeightWatch")
    ElseIf UO.SubExists("ManaWatch") Then
        UO.CallSub("ManaWatch")
    End If
END SUB

Sub ManaWatch()
    Dim sample
    For sample = 1 To 3
        If UO.Connected() Then
            UO.Print("Mana: " & CStr(UO.Mana()))
        End If
        UO.Wait(1000)
    Next
End Sub

Parameter and execution notes:

  • WeightWatch may come from another loaded file. When absent, the local ManaWatch is chosen. Finding a primary that cannot launch does not automatically choose the fallback.
  • Save each example as a separate file, load it in the IDE/manager and start Main so the other procedures are registered. WeightWatch/ManaWatch are fully defined teaching helpers: three weight/mana samples, Wait(1000) meaning 1000 ms, output only while in the world. They are finite monitors; pauses can extend elapsed time. The two-task example requires concurrent procedures to be enabled.

Check both definitions before starting

# Check both definitions before starting
#
# Checks for a procedure definition in the manager's current catalogue. Useful before launching
# an optional module; existence does not imply execution or eligibility for a zero-argument
# launch.
#
# Integer: 1 (True) when a definition is found; 0 (False) otherwise. If UO.SubExists(name), = 1
# and = True are valid; 0 corresponds to False. This does not check a disk file, validity or an
# active execution.

SUB Main()
    # HaveMonitors checks both names with AndAlso. If either is absent, Main starts neither. This
    # validates the definitions, not successful concurrent execution.
    # Save each example as a separate file, load it in the IDE/manager and start Main so the other
    # procedures are registered. WeightWatch/ManaWatch are fully defined teaching helpers: three
    # weight/mana samples, Wait(1000) meaning 1000 ms, output only while in the world. They are
    # finite monitors; pauses can extend elapsed time. The two-task example requires concurrent
    # procedures to be enabled.

    If HaveMonitors() Then
        UO.CallSub("WeightWatch")
        UO.CallSub("ManaWatch")
    End If
END SUB

Function HaveMonitors() As Boolean
    Return UO.SubExists("WeightWatch") AndAlso UO.SubExists("ManaWatch")
End Function

Sub WeightWatch()
    Dim sample
    For sample = 1 To 3
        If UO.Connected() Then
            UO.Print("Weight: " & CStr(UO.Weight()))
        End If
        UO.Wait(1000)
    Next
End Sub

Sub ManaWatch()
    Dim sample
    For sample = 1 To 3
        If UO.Connected() Then
            UO.Print("Mana: " & CStr(UO.Mana()))
        End If
        UO.Wait(1000)
    Next
End Sub

Parameter and execution notes:

  • HaveMonitors checks both names with AndAlso. If either is absent, Main starts neither. This validates the definitions, not successful concurrent execution.
  • Save each example as a separate file, load it in the IDE/manager and start Main so the other procedures are registered. WeightWatch/ManaWatch are fully defined teaching helpers: three weight/mana samples, Wait(1000) meaning 1000 ms, output only while in the world. They are finite monitors; pauses can extend elapsed time. The two-task example requires concurrent procedures to be enabled.

Clone this wiki locally