Difference between revisions of "AsOrd - StringUtil"

From the CreationKit Wiki
Jump to navigation Jump to search
imported>SniffleMan
(→‎Notes: Added note about decimal vs hex)
imported>SniffleMan
(→‎Parameters: Added notes about usage)
 
Line 12: Line 12:


== Parameters ==
== Parameters ==
*c: The character to convert to decimal.
*c: The character to convert to decimal. Converts only the first character in the given string.


== Return Value ==
== Return Value ==

Latest revision as of 17:53, 29 April 2018

SKSE Member of: StringUtil Script

Returns the decimal equivalent of the given character. (This function requires SKSE)

Syntax[edit | edit source]

int Function AsOrd(string c) global native

Parameters[edit | edit source]

  • c: The character to convert to decimal. Converts only the first character in the given string.

Return Value[edit | edit source]

The decimal equivalent of the passed character.
Returns 0 if the string was empty.

Examples[edit | edit source]

Import StringUtil

String myString = "a"
Int decimal = AsOrd(myString) ; decimal == 65 == A

myString = "A"
decimal = AsOrd(myString) ; decimal == 65 == A

myString = "Long string"
decimal = AsOrd(myString) ; decimal == 76 == L

myString = ""
decimal = AsOrd(myString) ; decimal == 0

Notes[edit | edit source]

This function returns the decimal equivalent, not the hexadecimal equivalent.
This function is case-insensitive (like all SKSE string functions right now).

See Also[edit | edit source]