-
Notifications
You must be signed in to change notification settings - Fork 0
API len en
Русский · English · Українська · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
ClassicUO • Runtime API
Checks text length for validation and labels, or the length of a number’s textual representation.
len(value:Decimal) -> Integer
len(value:Integer) -> Integer
len(value:String) -> Integer
-
value— String, Integer or Decimal. Numbers are formatted with invariant culture before counting; the minus sign and decimal point count too.
Integer count of UTF-16 code units. Empty text returns 0. An emoji can count as 2; combining marks also count separately. Numeric Len is text length, not the number’s storage size. Use GetArrayLength for an Array.
- Runs locally. Examples process sample data and return a value; they do not send chat, stop a script, move items or contact the server.
- No bytes, pixels, visible glyphs or nested array elements are counted. Text slicing by this count can split a surrogate pair; the abbreviation example deliberately uses ASCII names.
The String overload reads Length. Integer and Decimal overloads format with invariant culture, then read Length. No conversion or truncation of the original value occurs.
The String overload reads Length. Integer and Decimal overloads format with invariant culture, then read Length. No conversion or truncation of the original value occurs.
Integer count of UTF-16 code units. Empty text returns 0. An emoji can count as 2; combining marks also count separately. Numeric Len is text length, not the number’s storage size. Use GetArrayLength for an Array.
Project source: external/InjectionScript/src/InjectionScript/Runtime/InternalSubrutines.cs; function InternalSubrutines.Len.
No bytes, pixels, visible glyphs or nested array elements are counted. Text slicing by this count can split a surrogate pair; the abbreviation example deliberately uses ASCII names.
# Shorten a label
#
# Checks text length for validation and labels, or the length of a number’s textual
# representation.
#
# Integer count of UTF-16 code units. Empty text returns 0. An emoji can count as 2; combining
# marks also count separately. Numeric Len is text length, not the number’s storage size. Use
# GetArrayLength for an Array.
SUB Main()
# LongCharacterName exceeds 8 units. Taking five ASCII letters plus three dots returns LongC...,
# exactly 8 units.
# 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 label = "LongCharacterName"
If Len(label) > 8 Then
Return Left(label, 5) & "..."
End If
Return label
END SUBParameter and execution notes:
- LongCharacterName exceeds 8 units. Taking five ASCII letters plus three dots returns LongC..., exactly 8 units.
- Runs locally. Examples process sample data and return a value; they do not send chat, stop a script, move items or contact the server.
# Reject an empty setting
#
# Checks text length for validation and labels, or the length of a number’s textual
# representation.
#
# Integer count of UTF-16 code units. Empty text returns 0. An emoji can count as 2; combining
# marks also count separately. Numeric Len is text length, not the number’s storage size. Use
# GetArrayLength for an Array.
SUB Main()
# Trim removes the sample spaces. Len returns 0, so Main returns missing; a nonempty setting
# would be returned unchanged.
# 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 setting = Trim(" ")
If Len(setting) = 0 Then
Return "missing"
End If
Return setting
END SUBParameter and execution notes:
- Trim removes the sample spaces. Len returns 0, so Main returns missing; a nonempty setting would be returned unchanged.
- Runs locally. Examples process sample data and return a value; they do not send chat, stop a script, move items or contact the server.
# Distinguish character and numeric lengths
#
# Checks text length for validation and labels, or the length of a number’s textual
# representation.
#
# Integer count of UTF-16 code units. Empty text returns 0. An emoji can count as 2; combining
# marks also count separately. Numeric Len is text length, not the number’s storage size. Use
# GetArrayLength for an Array.
SUB Main()
# The emoji has length 2. -125 formats as four characters, including the sign. Main returns 2|4,
# not a byte count.
# 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 symbol = Chr(0x1F600)
Dim quantity = -125
Return CStr(Len(symbol)) & "|" & CStr(Len(quantity))
END SUBParameter and execution notes:
- The emoji has length 2. -125 formats as four characters, including the sign. Main returns 2|4, not a byte count.
- 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
Найти в справочнике
Клиент и скрипты
Каталоги значений
Разработка и помощь