Difference between revisions of "LlOrd"
Jump to navigation
Jump to search
Rider Linden (talk | contribs) |
Rider Linden (talk | contribs) |
||
Line 13: | Line 13: | ||
|caveats | |caveats | ||
|examples= | |examples= | ||
<source lang="lsl2"> | |||
default | |||
{ | |||
touch_start(integer total_number) | |||
{ | |||
string test_string = "The quick brown fox jumped over the lazy dog"; | |||
list test_list = []; | |||
string test_string2 = ""; | |||
integer index; | |||
integer ord; | |||
for (index = 0; index < llStringLength(test_string); ++index) | |||
{ | |||
ord = llOrd(test_string, index); | |||
test_list = test_list + [ ord ]; | |||
} | |||
string char; | |||
for (index = 0; index < llGetListLength(test_list); ++index) | |||
{ | |||
ord = llList2Integer(test_list, index); | |||
char = llChar(ord); | |||
test_string2 = test_string2 + char; | |||
} | |||
llSay(0, "\"" + test_string + "\" -> [" + | |||
llDumpList2String(test_list, ", ") + "] -> \"" + test_string2 + "\""); | |||
} | |||
} | |||
</source> | |||
|helpers|related | |helpers|related | ||
|also_functions= | |also_functions= |
Revision as of 15:48, 5 May 2021
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Summary
Function: integer llOrd( string val, integer index );? | Function ID |
0.0 | Forced Delay |
10.0 | Energy |
Calculate the ordinal value for a character in a string.
Returns an integer
• string | val | – | Source string for character ordinal. | |
• integer | index | – | Index of character ordinal to retrieve. |
The returned value is the UTF-32 value of the character at the specified index.
Caveats
Examples
default
{
touch_start(integer total_number)
{
string test_string = "The quick brown fox jumped over the lazy dog";
list test_list = [];
string test_string2 = "";
integer index;
integer ord;
for (index = 0; index < llStringLength(test_string); ++index)
{
ord = llOrd(test_string, index);
test_list = test_list + [ ord ];
}
string char;
for (index = 0; index < llGetListLength(test_list); ++index)
{
ord = llList2Integer(test_list, index);
char = llChar(ord);
test_string2 = test_string2 + char;
}
llSay(0, "\"" + test_string + "\" -> [" +
llDumpList2String(test_list, ", ") + "] -> \"" + test_string2 + "\"");
}
}