mIRC Home    About    Download    Register    News    Help

Print Thread
IF == comparing strings #52991 08/10/03 10:14 PM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline OP
Hoopy frood
OP Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
im looking but cant find a operator that seems to work, maybe its staring me in the face, but i cant find it.

I want to compare two strings to see if they match, ok easy you say
if (%s1 == %s2) { or if (%s1 === %s2) {

problem appears when strings happen to contain values

%s1 = 0098
%s2 = 98

They match, im assuming mircs doing a numeric adjustment to them and saying the values the same.

So Is there a STRING== ?

Re: IF == comparing strings #52992 08/10/03 10:22 PM
Joined: Dec 2002
Posts: 2,962
S
starbucks_mafia Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
Just add a non-numeric character to both strings. ie. if ($+(a,%s1) == $+(a,%s2))


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Re: IF == comparing strings #52993 08/10/03 10:27 PM
Joined: Dec 2002
Posts: 2,809
C
codemastr Offline
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 2,809
No there isn't, but that certainly doesn't prevent you from making your own:
Code:
alias comparecs {
  var %c = 1, %d = 1

  while ($mid($1,%c,1) === $mid($2,%d,1) && $ifmatch) {
    inc %c
    inc %d
  }
  if ($mid($1,%c,1) === $mid($2,%d,1)) return $true
  return $false
}


$comparecs(0098,98) = $false
$comparecs(test,TEST) = $false
$comparecs(test,test) = $true


Re: IF == comparing strings #52994 08/10/03 10:28 PM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline OP
Hoopy frood
OP Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
hmmm thanks, so simple yet i didnt think of it, just got to caught up looking for operator to think about adjusting the strings

Re: IF == comparing strings #52995 09/10/03 09:58 AM
Joined: Dec 2002
Posts: 191
N
Nobodi Offline
Vogon poet
Offline
Vogon poet
N
Joined: Dec 2002
Posts: 191
Could try $istok(%s1,%s2,32) .

Re: IF == comparing strings #52996 10/10/03 05:27 AM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline OP
Hoopy frood
OP Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
way to risky the strings might be
%s1 = bob the dog is here
%s2 = dog

Re: IF == comparing strings #52997 10/10/03 05:30 AM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline OP
Hoopy frood
OP Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Just thought id say, I didnt even do it ascomplexly as "if ($+(a,%s1) == $+(a,%s2))" i just went
IF (x %s1 == x %s2)