Difference between revisions of "Tutorial: String Variables 8"
Jump to navigation
Jump to search
imported>Odessa m |
imported>Odessa m |
||
Line 34: | Line 34: | ||
[[Tutorial: String Variables 9|Tutorial part 9: Replacing and Reassembling]] | [[Tutorial: String Variables 9|Tutorial part 9: Replacing and Reassembling]] | ||
==External Links== | |||
*[http://fallout.bethsoft.com/eng/links/privacyredirect.php?site=http://www.loverslab.com/topic/26963-tutorial-nvse4-part-3-string-variables/ This tutorial was originally adapted with permission from this forum post] | *[http://fallout.bethsoft.com/eng/links/privacyredirect.php?site=http://www.loverslab.com/topic/26963-tutorial-nvse4-part-3-string-variables/ This tutorial was originally adapted with permission from this forum post] | ||
[[Category:String Variables]] | [[Category:String Variables]] |
Revision as of 11:46, 9 July 2014
This is the eighth article in a tutorial series on string variables.
Measuring and Searching
Sv_Length returns the length of a string var's string:
let iSomeInt := sv_length sv_stringvar
Since the start position is always indexed at 0, the end position will always be (sv_length sv_stringvar) - 1.
Sv_Find finds the first occurrence of a substring in a string, and returns the position as an int:
let iSomeInt := sv_Find "substring" FormatSpecifierVars SourceStringVar StartPositionInt SearchLengthFromStartPosInt CaseSensitiveSearchBool ; leave out the parameters if you don't need them let sv_stringvar := "This is example 3" let iSomeInt1 := sv_Find "example %.0f" someInt2 sv_stringvar ; --> will return 8 if someInt2 is 3
Sv_Count returns just how many instances of a substring a string contains:
let sv_stringvar := "Ain't no sunshine when she's gone. And she's always gone too long." let iSomeInt := sv_Count "gone" sv_stringvar ; --> returns 2
Tutorial part 9: Replacing and Reassembling