String comparison

Post » Thu Aug 18, 2011 9:44 am

Hello @ll,

how is a string comparison done with obse / without obse?

a simple

string_var str1
string_var str2

if(str1 != str2)

won't work. Even the

sv_Compare str1 str2 > 0

does not. The latter ist for comparison string with formatted String anyway. but the first should work?
Thank you for any help.
User avatar
Dan Scott
 
Posts: 3373
Joined: Sun Nov 11, 2007 3:45 am

Post » Thu Aug 18, 2011 12:27 pm

Hello @ll,

how is a string comparison done with obse / without obse?

a simple

string_var str1
string_var str2

if(str1 != str2)

won't work.

Change to
if eval (str1 != str2)
...and they will work. The paranthesis is unnecessary, btw.

Even the

sv_Compare str1 str2 > 0

does not. The latter ist for comparison string with formatted String anyway.

...which means that you need to change it to:
sv_Compare "%z" str1 str2
...but "> 0" doesn't seem like what you want to check for.


You need "eval" added to any "if" statements that compare strings or array content. "eval" is a way to tell the engine to use OBSE's advanced functions instead of the standard engine's, which has no idea of string or array variables.
User avatar
Alkira rose Nankivell
 
Posts: 3417
Joined: Tue Feb 27, 2007 10:56 pm

Post » Fri Aug 19, 2011 12:48 am

Change to
if eval (str1 != str2)
...and they will work. The paranthesis is unnecessary, btw.


...which means that you need to change it to:
sv_Compare "%z" str1 str2
...but "> 0" doesn't seem like what you want to check for.


You need "eval" added to any "if" statements that compare strings or array content. "eval" is a way to tell the engine to use OBSE's advanced functions instead of the standard engine's, which has no idea of string or array variables.

many, many Thanks!! :icecream:
User avatar
Eire Charlotta
 
Posts: 3394
Joined: Thu Nov 09, 2006 6:00 pm


Return to IV - Oblivion