Difference between revisions of "Tutorial: String Variables 8"

From the Fallout3 GECK Wiki
Jump to navigation Jump to search
imported>Odessa
m
imported>Gribbleshnibit8
m (Added NVSE and Tutorials Categories)
 
Line 39: Line 39:
*[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:NVSE]]
[[Category:String Variables]]
[[Category:String Variables]]
[[Category:Tutorials]]

Latest revision as of 12:10, 3 May 2015

This is the eighth article in a tutorial series on string variables.

Measuring and Searching[edit | edit source]

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

External Links[edit | edit source]