Skip to content

API Basic SafeCall en

Codex edited this page Sep 21, 2026 · 1 revision

Safe Call

ClassicUO • Basic

Safe Call is a compatibility prefix for an ordinary call. It adds no error protection, timeout, lock, or background execution.

Exact syntax

Safe Call FunctionName(arguments)
VAR value = Safe Call FunctionName(arguments)

Parameters

  • FunctionName — The name of an existing procedure/function. Game calls require UO.; BASIC built-ins use no prefix.
  • arguments — The normal arguments of the selected function. Parentheses are required. Use spaces between Safe and Call.

Returns

The original function result is returned. Unit still means no value; Safe Call does not convert the result to true/false.

Behavior

  • Execution stays in the current script flow with normal argument, ByRef, return and cancellation rules. No separate task is created.
  • Errors are not suppressed. Use Try/Catch to handle them; Safe Call alone is not an error handler.
  • The prefix is not allowed in RaiseEvent. New code can normally use FunctionName(...) directly. This is engine compatibility syntax, not a standard VB.NET construct.

Examples

1. Call a user function

# Sum receives x=20 and y=22 and returns 42. Safe Call changes neither the result type nor the number.
FUNCTION Sum(x, y)
    RETURN x + y
END FUNCTION
SUB Main()
    RETURN Safe Call Sum(20, 22)
END SUB

Parameter and execution notes:

Sum receives x=20 and y=22 and returns 42. Safe Call changes neither the result type nor the number.

2. Use a built-in result in an expression

# Val receives "123" and returns a number. Adding 7 gives 130. Val is a BASIC built-in, so do not add UO.
SUB Main()
    VAR text = "123"
    RETURN Safe Call Val(text) + 7
END SUB

Parameter and execution notes:

Val receives "123" and returns a number. Adding 7 gives 130. Val is a BASIC built-in, so do not add UO.

3. Catch an error explicitly

# Fail explicitly throws an error. Catch receives it and sets caught to TRUE (1). Without Try/Catch it would propagate. The full Fail implementation is included below.
FUNCTION Fail()
    THROW "sample error"
END FUNCTION
SUB Main()
    VAR caught = FALSE
    TRY
        VAR value = Safe Call Fail()
    CATCH problem
        caught = TRUE
    END TRY
    RETURN caught
END SUB

Parameter and execution notes:

Fail explicitly throws an error. Catch receives it and sets caught to TRUE (1). Without Try/Catch it would propagate. The full Fail implementation is included below.

ru · en · uk · de · fr · it · es · zh-tw · ja · ko

Basic

Clone this wiki locally