Difference between revisions of "GetSubString"

From NWN Lexicon
Jump to: navigation, search
m (Wikified article formatting)
Line 1: Line 1:
 
 
 
 
=GetSubString(string, int, int)=
 
 
 
Get a substring from within a string.
 
Get a substring from within a string.
  
Line 15: Line 9:
 
</nwscript>
 
</nwscript>
  
====Parameters====
+
===Parameters===
 
 
''sString''
 
 
 
Target string.
 
 
 
''nOffset''
 
 
 
Character offset.
 
 
 
''nCount''
 
  
Number of characters in substring.
+
; sString
 +
: Target string.
  
<br />
+
; nOffset
 +
: Character offset.
  
====Description====
+
; nCount
 +
: Number of characters in substring.
  
 +
===Description===
 
Returns a substring of sString containing nCount characters starting from offset nOffset. Returns an empty string on error.
 
Returns a substring of sString containing nCount characters starting from offset nOffset. Returns an empty string on error.
  
<br /><br />
+
===Remarks===
 
 
====Remarks====
 
 
 
 
The parameter nOffset begins with 0 for the first character in a string, 1 for the second character, 2 for the third character and so on.
 
The parameter nOffset begins with 0 for the first character in a string, 1 for the second character, 2 for the third character and so on.
  
<br />
+
===Version===
 
 
====Version====
 
 
 
 
1.22
 
1.22
  
====Example====
+
===Example===
  
 
<nwscript>
 
<nwscript>
Line 62: Line 44:
 
</nwscript>
 
</nwscript>
  
====See Also====
+
===See Also===
  
 
{| class="seealso"
 
{| class="seealso"
 
| width="1px" align="right" valign="top" | <font color="gray">functions: </font>
 
| width="1px" align="right" valign="top" | <font color="gray">functions: </font>
|
+
| [[FindSubString]], [[GetStringRight]], [[GetStringLeft]]
[[ GetStringRight  | GetStringRight ]]
 
 
|-
 
|-
 
|}
 
|}
  
<br />
 
 
----
 
----
<font color="gray">  author: Kristian Markon, editor: Daniel Beckman</font><br />  <br />
+
<font color="gray">  author: Kristian Markon, editor: Daniel Beckman</font>
 
[[Category:Functions]]
 
[[Category:Functions]]
 
[[Category:String_Functions]]
 
[[Category:String_Functions]]
 +
{{DISPLAYTITLE:GetSubString(string, int, int)}}

Revision as of 15:35, 3 February 2020

Get a substring from within a string.

string GetSubString(
    string sString,
    int nOffset,
    int nCount
);

Parameters

sString
Target string.
nOffset
Character offset.
nCount
Number of characters in substring.

Description

Returns a substring of sString containing nCount characters starting from offset nOffset. Returns an empty string on error.

Remarks

The parameter nOffset begins with 0 for the first character in a string, 1 for the second character, 2 for the third character and so on.

Version

1.22

Example

void main()
{
    string sString = "Hello World!";
 
    // say "Hello"
    SpeakString(GetSubString(sString, 0, 5));
 
    // say "World!"
    SpeakString(GetSubString(sString, 6, 6));
}

See Also

functions:  FindSubString, GetStringRight, GetStringLeft

 author: Kristian Markon, editor: Daniel Beckman