Difference between revisions of "Tutorial: String Variables 5"
Jump to navigation
Jump to search
imported>Odessa |
imported>Odessa m |
||
Line 34: | Line 34: | ||
==External Links== | ==External Links== | ||
*[http://www.loverslab.com/topic/26963-tutorial-nvse4-part-3-string-variables/ | *[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:44, 9 July 2014
This is the fifth article in a tutorial series on string variables.
Checking String Variables
With 'if eval' syntax, checking whether a string var is the same as another, or the same as a string, is as simple as:
if eval my_stringvar == "some string" ... if eval my_stringvar1 == my_stringvar2 ...
and you can use != too for inequality.
Before eval, you had to check the int value returned by the Sv_Compare function if you wanted to compare a string var to a string:
if 0 == sv_compare "some string" FormatSpecVars sv_stringvar bCaseSensitiveComparebool ; they are the same elseif 1 == sv_compare "some string" FormatSpecVars sv_stringvar bCaseSensitiveComparebool ; the string var's string occurs before the string, alphabetically speaking elseif -1 == sv_compare "some string" FormatSpecVars sv_stringvar bCaseSensitiveComparebool ; the string var's string occurs after the string, alphabetically speaking elseif -2 == sv_compare "some string" FormatSpecVars sv_stringvar bCaseSensitiveComparebool ; none of the above, the compare 'fails' endif
Not much point in using sv_compare, now that we have the "if eval" alternative, except if you're really interested in the alphabetical comparison. These comparisons are case-insensitive, unless you use that bool with sv_compare.
Tutorial part 6: Passing String Vars as parameters