Tutorial: String Variables 5
From GECK
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