About: GetSubString   Sponge Permalink

An Entity of Type : owl:Thing, within Data Space : 134.155.108.49:8890 associated with source dataset(s)

function GetSubString (string sString, int nStart, int nCount) Get nCount characters from sString, starting at nStart * Return value on error: "" * Return type: string * Include file: nwscriptdefn

AttributesValues
rdfs:label
  • GetSubString
rdfs:comment
  • function GetSubString (string sString, int nStart, int nCount) Get nCount characters from sString, starting at nStart * Return value on error: "" * Return type: string * Include file: nwscriptdefn
  • The GetSubString() NWScript command extracts a portion of a string as a new string. If an error is encountered (such as trying to obtain a string of negative length), a zero-length string, "", is returned.
  • Beware: invalid values for the nCount parameter can crash the game. NWN2 script doesn't support the idiom of leaving out the nCount parameter if the rest of the string from nStarts onwards is desired, and so the textbook method for getting the rest of a string from nStart onwards is this: string sRest = GetSubString(sString, nStart, GetStringLength(sString) - nStart); This should be safe provided that nStart is between 0 and the string length. Now, one might be tempted to avoid the overhead of the GetStringLength() call, and use a ploy common in other languages:
param3desc
  • The number of characters to be extracted.
dcterms:subject
dbkwik:nwn2/proper...iPageUsesTemplate
returns
Name
  • GetSubString
param
  • string sString
  • int nStart
  • int nCount
param2desc
  • The character of at which the substring begins. This is zero-based, so the first character is 0, the second is 1, etc.
param1desc
  • The string from which a substring will be extracted.
dbkwik:nwn/property/wikiPageUsesTemplate
abstract
  • Beware: invalid values for the nCount parameter can crash the game. NWN2 script doesn't support the idiom of leaving out the nCount parameter if the rest of the string from nStarts onwards is desired, and so the textbook method for getting the rest of a string from nStart onwards is this: string sRest = GetSubString(sString, nStart, GetStringLength(sString) - nStart); This should be safe provided that nStart is between 0 and the string length. Now, one might be tempted to avoid the overhead of the GetStringLength() call, and use a ploy common in other languages: string sRest = GetSubString(sString, nStart, INT_MAX); This may work everywhere else, but in NWN2 it crashes the game hard. In cursory testing of GetSubString("GetSubString", 3, n); the game did not crash for n up to 500000000 and it did crash immediately for n = 600000000. However, this doesn't mean that values up to 500000000 are safe. It just means that the game didn't crash right away but there might still be undiscovered damage that could lead to a crash sometime later. Unless and until further information emerges, the only method that can be considered truly safe is the textbook method. Caveat emptor.
  • function GetSubString (string sString, int nStart, int nCount) Get nCount characters from sString, starting at nStart * Return value on error: "" * Return type: string * Include file: nwscriptdefn
  • The GetSubString() NWScript command extracts a portion of a string as a new string. If an error is encountered (such as trying to obtain a string of negative length), a zero-length string, "", is returned.
Alternative Linked Data Views: ODE     Raw Data in: CXML | CSV | RDF ( N-Triples N3/Turtle JSON XML ) | OData ( Atom JSON ) | Microdata ( JSON HTML) | JSON-LD    About   
This material is Open Knowledge   W3C Semantic Web Technology [RDF Data] Valid XHTML + RDFa
OpenLink Virtuoso version 07.20.3217, on Linux (x86_64-pc-linux-gnu), Standard Edition
Data on this page belongs to its respective rights holders.
Virtuoso Faceted Browser Copyright © 2009-2012 OpenLink Software