Tutorial: String Variables 8

From the Fallout3 GECK Wiki
Revision as of 11:46, 9 July 2014 by imported>Odessa
Jump to navigation Jump to search

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