mIRC Home    About    Download    Register    News    Help

Print Thread
#181037 16/07/07 09:46 PM
Joined: Jan 2004
Posts: 509
L
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Jan 2004
Posts: 509
Code:
on *:text:*:*: {
  if (This) {
    do this
  }
  if (That) {
    do that
  }
  if (This2) {
    do this2
  }
  if (That2) {
    do that2
  }
}


Notice, I didn't have a /halt anywhere.

Or.

Code:
on *text:*:*: {
  if (Not this) /halt
  if This {
    Do stuff
  }
}

on *text:*:*: {
  if (Not that) /halt
  if That {
    Do stuff
  }
}

on *text:*:*: {
  if (Not this2) /halt
  if This2 {
    Do stuff
  }
}

on *text:*:*: {
  if (Not that2) /halt
  if That2 {
    Do stuff
  }
}


(In separate sheets).

Notice all of them check for halts in the beginning.

In other words, I was asking are you better off combining all on text events as 1, or to split them up so you can use more halts..

But the more on text events you have, the more mIRC has to process for each text event. But having less and less on text event, means using less halts and for mIRC to go through the entire on text event.

The point for the 1st 1 is that the on text events could be completely different, that I wouldn't want to add a halt anywhere in the beginning except at the very end, but at the very very end wouldn't help mean anything.

-Neal.

Joined: Dec 2002
Posts: 2,031
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Dec 2002
Posts: 2,031
I believe the first would be faster as long as you use elseif...

Code:
on *:TEXT:*:*: {
  if (This) {
    do this
  }
  elseif (That) {
    do that
  }
  elseif (This2) {
    do this2
  }
  elseif (That2) {
    do that2
  }
}

RoCk #181044 16/07/07 10:41 PM
Joined: Apr 2006
Posts: 464
O
Fjord artisan
Offline
Fjord artisan
O
Joined: Apr 2006
Posts: 464
And with the If, Elseif, Elseif, etc construction, there is also no need for any /halt. Since it won't process the rest of that particulair comparison anyway.

I'm convinced that combining all comparisons into 1 on TEXT event, with the proper if, elseif, elseif etc construction is fastest way.

Joined: Jan 2004
Posts: 509
L
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Jan 2004
Posts: 509
Problem is the if (this) and (that) are completely different scripts.

So, for my specific exaple.

Code:
on *:text:*:#: { 
  if (a script that checks for $me that playing sound, /echo, etc.)
  if (something that checks if a certain word is in the $1- and /echo or /write it)
  if (a calculator script where if + or -, etc, isin $1-, with numbers, it relays the answer, i.e., 10 + 10, /msg's 20.
  if (a script that puts all text and previous text into variables).
  if (checks if the $target is channel and if I have a pm window open with $nick to echo the text there).
}


Now these if's additional can have their own elseif and else inside. smirk

But I was thinking of breaking each of them up to their own on text event if they're not related, then I can use the /halt.

on text {
if ($me is not in it) halt
continue
}

on text {
if (no numbers in it) halt
continue calculate script
}

And each of those individually can have their elseifs and elses.

-Neal.

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Remember mIRC is processing linear. The one-event-sollution could therefore "look" cleaner, a multi-event-sollution won't be faster. Concerning speed issues:

1) use elseif / else wherever possible
2) a single-event-sollution could be faster if you want to process specific conditions twice or more. If e.g. the number if uppercase chars in text matters twice, why should you calculate them twice? the calculation could be done once in the "header" of your "master" on-text-event
3) sort the processing order of all if-statements from "easiest" to "most complex"
e.g.
do not use:
Code:
if ( ((!$findfile(something)) && ($regex($1-,somecomplexregex))) || ($me !isreg $chan)) { stuff }
but:
Code:
if (($me !isreg $chan) || (($regex($1-,somecomplexregex)) && (!$findfile(something))) ) { stuff }
(assuming that findfile takes most time, !isreg comparison the least)
But there are also disadvantages for a single on-text-event (merging all events might make debugging / changing a specific part / using switches etc harder)

_____

And why do you use (quote):
Code:
on text {
  if (no numbers in it) halt
  continue calculate script
}
and not:
Code:
on text { 
  if (numbers in it) { calculate }
}
imho that looks clearer

Last edited by Horstl; 17/07/07 12:03 AM.
Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
Well the decision is pretty much made for you by mIRC. mIRC will only process the first matching event in each script file, so you don't have much choice but to use if's. That is unless each of the text events you're using have different criteria that can be specified in the even definition itself - ie. the userlevel, matchtext, and location parameters (on [color:red]userlevel:text:matchtext:location:{ ... }[/color]) in which case that'll be the fastest way to go.


Spelling mistakes, grammatical errors, and stupid comments are intentional.

Link Copied to Clipboard