mIRC Home    About    Download    Register    News    Help

Print Thread
#158060 31/08/06 02:51 PM
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
if (np* iswm #) do something

if (np isin #) do something

both the same thing right, for what i need?

#158061 31/08/06 03:09 PM
Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
Code:
if (np* iswm #) do something

will always be false because the channel name would have to start with 'np', which is impossible since it must always start with the channel prefix (usually #, &, or +).



Code:
if ([color:red]*[/color]np* iswm #) do something
is equivalent to:
if (np isin #) do something


Spelling mistakes, grammatical errors, and stupid comments are intentional.
#158062 31/08/06 03:58 PM
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
ahhh i see now thanks!!

whats the point of mirc having iswm and isin then?

#158063 31/08/06 04:14 PM
Joined: Mar 2005
Posts: 420
X
Fjord artisan
Offline
Fjord artisan
X
Joined: Mar 2005
Posts: 420
'iswm' needs a wildcard while 'isin' does not. Sometimes you need to compare 2 items like you want to see if the first word in a text matches '!test'. If you use 'isin' & !test is also in the middle of the text, then that condition would be true as well.

Sample:

if (!test* iswm !test this) <- would be true
if (!test isin use !test <trigger>...) <- would be true also

See the difference?


If you have a plastic floor runner over your tiles, then you're one Hella Pinoy!
#158064 31/08/06 04:21 PM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
As opposed to only having iswm? The reason might simply be that isin was added first (being simpler to code). Regardless, there are a few advantages of having both:

[*]How would you check if the literal characters *, ? or & are inside a string with iswm? Similarly, how would you check if a dynamic string (like $1) is part of another string, without worrying that any *, ? and & inside $1 are going to be interpreted as wildcards (e.g. if ($1 isin %blah) )?

[*]if (blah isin $1) is a little shorter and faster than if (*blah* iswm $1)


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
#158065 01/09/06 04:04 AM
Joined: Feb 2005
Posts: 342
R
Fjord artisan
Offline
Fjord artisan
R
Joined: Feb 2005
Posts: 342
Why have both, you ask?

The answer is really quite simple.

"isin" works fine and dandy for figuring out if something is in a string, so as hixxy noted, this type of "check" is probably one of the fastest. You can only check for a single word or group of characters with this, however.

"iswm" gives you the advantage of matching beyond just one or two characters:

Let's say: $1- == The dog takes flight on tuesday
Code:
if (* dog * flight * tuesday iswm $1-) {
  ; This would be true!
  ; There must be atleast one word (or more) before "dog"
  ; There must be one or more words between dog and flight.
  ; There must be one or more words between flight and tuesday.
  ; tuesday must be the last word in the string.
}


This allows you to see if "dog" "flight" and "tuesday" are in a sentence, no matter how many words are between them, so long as "tuesday" is the last word in the string, and so long as there is atleast one word before "dog"

#158066 01/09/06 06:25 AM
Joined: Mar 2005
Posts: 420
X
Fjord artisan
Offline
Fjord artisan
X
Joined: Mar 2005
Posts: 420
I think this reply is for pouncer.


If you have a plastic floor runner over your tiles, then you're one Hella Pinoy!
#158067 01/09/06 07:11 AM
Joined: Feb 2005
Posts: 342
R
Fjord artisan
Offline
Fjord artisan
R
Joined: Feb 2005
Posts: 342
Strange, thought I hit his reply and not yours. Oh well. It was targetted at him. I knew he was the one that asked "Why"

#158068 01/09/06 09:55 AM
Joined: Jan 2003
Posts: 1,063
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2003
Posts: 1,063
Quote:

Code:
if (* dog * flight * tuesday iswm $1-) {
  ; This would be true!
  ; There must be atleast one word (or more) before "dog"
  ; There must be one or more words between dog and flight.
  ; There must be one or more words between flight and tuesday.
  ; tuesday must be the last word in the string.
}



* means 0 or more... not 1 or more
so "_dog__flight__tuesday_" would match aswell (think of the underscores as spaces)


If it ain't broken, don't fix it!
#158069 02/09/06 02:13 PM
Joined: Feb 2005
Posts: 342
R
Fjord artisan
Offline
Fjord artisan
R
Joined: Feb 2005
Posts: 342
* matches 0 or more, yes.

But in my little example, you'll notice I'm comparing it to $1-, which removes excess white space.

And since we're getting really picky: "_dog__flight__tuesday_"

I want you to open up your mIRC scripts editor, go to variables, and enter:

Code:
%test this____is___a__test_


Replace the _'s with spaces. Then press OK.
Now in mIRC's editbox: //echo -ag $iif(* test iswm %test,yes,no)

First thing you'll notice, it's not true.
Trailing spaces obviously do matter, though generally, you won't have trailing spaces. But the point still stands.

It's generally a good idea to make sure what you say is correct if you're going to correct someone on something extremely miniscule. Cause I, and probably many others, will return the favor.

When I said "one or more words" it's because the wild card is between two spaces. Doing that comparison on something like: $1-, means you're going to have the excess spaces stripped out. Meaning there has to be one or more words or one or more characters in order for it to trigger, as you won't have two consecutive spaces using $1- on 99% of the ocassions.


Link Copied to Clipboard