Difference between revisions of "String"

From NWN Lexicon
Jump to: navigation, search
(Added info on escaping characters)
Line 1: Line 1:
{{DISPLAYTITLE:string}}
+
A sequence of characters of arbitrary length. The default value is an empty string (""). Strings can be concatenated (that is, combined) by using the plus ("+") sign. A string can be compared for equality against another string by using the double equals ("==") equality tester, or for inequality by using the "!=" equality tester. When testing for string equality, strings are case-sensitive (that is "SoME CHaRaCTeR NaMe" does not equal "some character name").
A sequence of characters of arbitrary length. The default value is an empty string (""). Strings can be concatenated (that is, combined) by using the plus ("+") sign. A string can be compared for equality against another string by using the double equals ("==") equality tester, or for inequality by using the "!=" equaliter tester. When testing for string equality, strings are case-sensitive (that is "SoME CHaRaCTeR NaMe" does not equal "some character name").
 
  
 
====Example====
 
====Example====
 
<nwscript>
 
<nwscript>
 
string sHero = "Galryx";
 
string sHero = "Galryx";
 +
</nwscript>
 +
 +
====Escaped Characters====
 +
Some characters may be preceded by a backslash (<span class="code">\</span>) to generate special characters. This is called escaping the character. For example, <span class="code">\t</span> results in a tab character and <span class="code>\n</span> results in a newline character.
 +
{{NWNEE|type=section}}
 +
As of NWN:EE version [https://trello.com/c/eQMuo2Cu/113-features 74.8168], strings may now contain double-quote characters if the double-quote is escaped using a backslash. For example:
 +
<nwscript>
 +
void main()
 +
{
 +
    // The NPC says: So I respond, "That's what she said!"
 +
    SpeakString("So I respond, \"That's what she said!\"");
 +
}
 
</nwscript>
 
</nwscript>
  
Line 10: Line 21:
 
[[:Category:String_Functions|String Functions]]
 
[[:Category:String_Functions|String Functions]]
 
----
 
----
[[Category:Data_Types]]
+
[[Category:Data_Types]]{{DISPLAYTITLE:string}}

Revision as of 01:26, 22 April 2018

A sequence of characters of arbitrary length. The default value is an empty string (""). Strings can be concatenated (that is, combined) by using the plus ("+") sign. A string can be compared for equality against another string by using the double equals ("==") equality tester, or for inequality by using the "!=" equality tester. When testing for string equality, strings are case-sensitive (that is "SoME CHaRaCTeR NaMe" does not equal "some character name").

Example

string sHero = "Galryx";

Escaped Characters

Some characters may be preceded by a backslash (\) to generate special characters. This is called escaping the character. For example, \t results in a tab character and \n results in a newline character.

Nwnee logo.jpg Note: This section documents Neverwinter Nights: Enhanced Edition new content or changes/updates/fixes to 1.69 functions. These are all listed under the category and patches pages.

As of NWN:EE version 74.8168, strings may now contain double-quote characters if the double-quote is escaped using a backslash. For example:

void main()
{
    // The NPC says: So I respond, "That's what she said!"
    SpeakString("So I respond, \"That's what she said!\"");
}

See Also

String Functions