Sv Find
Jump to navigation
Jump to search
< [[::Category:Functions|Category:Functions]]
A function added by the New Vegas Script Extender.
Description
Added by NVSE V4. Returns the position of the first occurence of a string in a string variable.
The first argument is a string, which may have optional formatting information thereafter. This is what you want to find.
The second argument (ignoring the optional formatting) is a string variable within which to search for the first string.
There are three optional int arguments at the very end: a start position and end position, which allow searching of a substring of the string_var, and finally, a boolean flag to enable case sensitivity.
Syntax
(int) Sv_Find ToFind:string 20xOptional:formatting Within:string_var StartPos:int EndPos:int CaseSensitiveFlag:int
Minimum Syntax
(int) Sv_Find ToFind:string Within:string_var
Example
Sv_Find "this", MyStringVar
Additional Context
string_var my_message let my_message := "The owls are not what they seem" Sv_Find "e", my_message ; will return 2, the first 'e' Sv_Find "the", my_message ; will return 0, note case insensitivy- it found 'The' Sv_Find "owls", my_message ; will return 4 Sv_Find "something that isn't in the string", my_message ; will return -1
Warning, remember it returns the position, not true or false. Hence:
string_var my_instructions let my_instructions := "Do Something" if eval (Sv_Find "Do Something", my_instructions) ; Is False, because it returns zero as the found position endif if (Sv_Find "Not in string", my_instructions) ; Is True, because it returns -1 for 'not found', and that reduces to true endif ; * If you just want to know if something was found, use this: if eval (Sv_Find "Do Something", my_instructions) > -1 ; Do something is somewhere in the variable endif