-
Notifications
You must be signed in to change notification settings - Fork 0
API StrComp en
Русский · English · Українська · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
ClassicUO • Runtime API
Compares names or command text when exact equality and a stable ordering are needed.
StrComp(left:String, right:String) -> Integer
-
left— Left String to compare. -
right— Right String to compare. Both parameters are required; there is no third comparison-mode parameter.
Integer -1 if left sorts before right, 0 if equal, or 1 if after, using case-sensitive ordinal UTF-16 comparison. This is not Boolean: equality means result = 0. A plain If StrComp(...) is true for unequal strings.
- Runs locally. Examples process sample data and return a value; they do not send chat, stop a script, move items or contact the server.
- Comparison is independent of the interface language and does not perform natural-language sorting or case folding. If your rule ignores case, normalize explicitly with LCase or UCase. Neither input is changed.
BasicStrComp performs String.Compare with Ordinal, then Math.Sign reduces the result to -1, 0 or 1.
BasicStrComp performs String.Compare with Ordinal, then Math.Sign reduces the result to -1, 0 or 1.
Integer -1 if left sorts before right, 0 if equal, or 1 if after, using case-sensitive ordinal UTF-16 comparison. This is not Boolean: equality means result = 0. A plain If StrComp(...) is true for unequal strings.
Project source: external/InjectionScript/src/InjectionScript/Runtime/InjectionApi.cs; function BasicStrComp / String.Compare / Math.Sign.
Comparison is independent of the interface language and does not perform natural-language sorting or case folding. If your rule ignores case, normalize explicitly with LCase or UCase. Neither input is changed.
# Recognize a normalized command
#
# Compares names or command text when exact equality and a stable ordering are needed.
#
# Integer -1 if left sorts before right, 0 if equal, or 1 if after, using case-sensitive ordinal
# UTF-16 comparison. This is not Boolean: equality means result = 0. A plain If StrComp(...) is
# true for unequal strings.
SUB Main()
# Trim and LCase turn " STOP " into stop. Explicit equality to 0 returns True (1). This checks
# the text; it does not stop any running script.
# Runs locally. Examples process sample data and return a value; they do not send chat, stop a
# script, move items or contact the server.
Dim action = LCase(Trim(" STOP "))
If StrComp(action, "stop") = 0 Then
Return True
End If
Return False
END SUBParameter and execution notes:
- Trim and LCase turn " STOP " into stop. Explicit equality to 0 returns True (1). This checks the text; it does not stop any running script.
- Runs locally. Examples process sample data and return a value; they do not send chat, stop a script, move items or contact the server.
# Order two resource names
#
# Compares names or command text when exact equality and a stable ordering are needed.
#
# Integer -1 if left sorts before right, 0 if equal, or 1 if after, using case-sensitive ordinal
# UTF-16 comparison. This is not Boolean: equality means result = 0. A plain If StrComp(...) is
# true for unequal strings.
SUB Main()
# zinc compares after iron, so local variables are swapped. Main returns iron|zinc; this is
# ordinal order, not a full inventory sort.
# Runs locally. Examples process sample data and return a value; they do not send chat, stop a
# script, move items or contact the server.
Dim first = "zinc"
Dim second = "iron"
If StrComp(first, second) > 0 Then
Dim saved = first
first = second
second = saved
End If
Return first & "|" & second
END SUBParameter and execution notes:
- zinc compares after iron, so local variables are swapped. Main returns iron|zinc; this is ordinal order, not a full inventory sort.
- Runs locally. Examples process sample data and return a value; they do not send chat, stop a script, move items or contact the server.
# Find an exact allowed name
#
# Compares names or command text when exact equality and a stable ordering are needed.
#
# Integer -1 if left sorts before right, 0 if equal, or 1 if after, using case-sensitive ordinal
# UTF-16 comparison. This is not Boolean: equality means result = 0. A plain If StrComp(...) is
# true for unequal strings.
SUB Main()
# ContainsExact splits the sample list with | and compares each name to Ore. It returns True (1)
# only on exact equality; ore alone would not match Ore.
# Runs locally. Examples process sample data and return a value; they do not send chat, stop a
# script, move items or contact the server.
Return ContainsExact("ore|Ore|wood", "Ore")
END SUB
Function ContainsExact(names, wanted)
For index = 0 To GetWordCount(names, "|") - 1
If StrComp(GetWord(names, index, "|"), wanted) = 0 Then
Return True
End If
Next
Return False
End FunctionParameter and execution notes:
- ContainsExact splits the sample list with | and compares each name to Ore. It returns True (1) only on exact equality; ore alone would not match Ore.
- Runs locally. Examples process sample data and return a value; they do not send chat, stop a script, move items or contact the server.
ClassicUO
Bad Newbie & Basic IDE
Найти в справочнике
Клиент и скрипты
Каталоги значений
Разработка и помощь