mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 2 1 2
Joined: Dec 2006
Posts: 3
T
Teh_BaK Offline OP
Self-satisified door
OP Offline
Self-satisified door
T
Joined: Dec 2006
Posts: 3
I've got a massive list of raws in my bloated script, obviously its
raw *:*: {

followed by a LOT of :
if ($numeric == 369) { do stuff }
lines, and it appears that the first 130 lines work fine, but the last lines dont. i've tried put it in another "raw *:*: {" but it didnt work.

I am currently, after having some time away from IRC and mIRC scripting, upgrading my script to the latest 6.x due to them windows exploits. It worked fine in 6.03, and i dont know when it stopped working.

Does anyone else have this problem before i bug report it? maybe its something i've missed as a 'feature' or a security thing? Just it really does make my script unuseable, and i've been working on it since ~2000. Any help would be greatly appreciated.

Joined: Oct 2003
Posts: 313
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Oct 2003
Posts: 313
I just created a raw *:*: { ... } script with a few lines, all of the form:
Code:
 
  if ($numeric == 369) { echo -s RPL_ENDOFWHOWAS }


(nice, easy cut and paste and regex sub). That line (for 369) is on line 155 (including a couple of comments and a few blank lines).

All seems to work without a problem.

You might want to move it around in your script (or just throw in some echoes) to identify the line where the problem occurs.

Last edited by Sais; 12/12/06 04:52 PM.

Sais
Joined: Dec 2006
Posts: 3
T
Teh_BaK Offline OP
Self-satisified door
OP Offline
Self-satisified door
T
Joined: Dec 2006
Posts: 3
I've done the echo thing, thats how i found it was there. Its approx the 50th if statement in the raw event.

The more echos i added before that line (even made it echo over 5 lines, includind the line that numeric is on) and it echo'd them fine, and then stoped on the next 'if ($numeric'.

There are several if statements that take multiple lines, and one if statement thats not a numeric (for debuging).

Joined: Jan 2003
Posts: 1,063
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2003
Posts: 1,063
who not use the 'raw 369:*: { ... }' syntax to devide all the events?

and these questions are better suited for the script part of the forum...


If it ain't broken, don't fix it!
Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
If your code is just checking $numeric each time you should be using elseif instead of if, it might work out much faster (although it still wouldn't explain why your code isn't working).

This also might be a place where using goto will be the most efficient method.

ie.

Code:
raw *:*:{
  goto $numeric {
    :001
    ;dostuff for numeric 001
    goto end
    :002
    ;dostuff for numeric 002
    goto end
    ;more numerics here!
    :error
    if (? /goto: * iswm $error) reseterror
    :end
  }
}


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Personally, I'd stick the the method Dognatch suggested. It's much cleaner, imo.

As for the problem with it failing, it would help if you (OP) can paste about 10 lines or so around the one you think is bad -- starting about 5 lines before and going to about 5 lines after. That will let us see what's going on around it in case there is something messed up nearby and it really isn't the line you think it is.


Invision Support
#Invision on irc.irchighway.net
Joined: Dec 2006
Posts: 3
T
Teh_BaK Offline OP
Self-satisified door
OP Offline
Self-satisified door
T
Joined: Dec 2006
Posts: 3
I found the issue. After writing a MASSIVE reply. Typicaly a single character... Cheers for your patience ;]

starbucks_mafia, nice idea, i didnt realise you could do that.

if ($numeric == 369) { haltdef | ; & ยป End Of Whowas }

This was the line causing my grief. the ; canceled the bracket, but mIRC editor didnt pick up on it when i clicked {}. Not the bug i thought, but one regardless.

Joined: Feb 2006
Posts: 546
J
Fjord artisan
Offline
Fjord artisan
J
Joined: Feb 2006
Posts: 546
Originally Posted By: starbucks_mafia

Code:
raw *:*:{
  goto $numeric {
    :001
    ;dostuff for numeric 001
    goto end
    :002
    ;dostuff for numeric 002
    goto end
    ;more numerics here!
    :error
    if (? /goto: * iswm $error) reseterror
    :end
  }
}


i like the extra { } to make it more legible laugh here's a simpler alternative to the error handling though, with a couple of small changes that seemed more intuitive to me:

Code:
raw *:*:{
  var %e = $event
  goto %e {
    :001
    ;dostuff for numeric 001
    return
    :002
    ;dostuff for numeric 002
    return
    ;more numerics here!
    :%e
  }
}


$event so it'll support non numeric ones too, just in case :X


"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde
Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
If we are throwing out methods, I might use something like this:

Code:
raw *:*:{
  var %alias = $+(raw_,$right($+(000,$numeric),3))
  if ($isalias(%alias)) %alias
}

alias raw_001 { echo -a Raw 001 }
alias raw_002 { echo -a Raw 002 }
alias raw_003 { echo -a Raw 003 }


Just another option. :P

-genius_at_work

Joined: Apr 2003
Posts: 342
M
Fjord artisan
Offline
Fjord artisan
M
Joined: Apr 2003
Posts: 342
Umm... I'd use the SIGNAL event... with hash tables...


Code:
raw *:*: {
   if $hget(h.numeric) { /.hfree h.numeric }
      /.hmake h.numeric 100
      /.hadd h.numeric NUMERIC $numeric
      /.hadd h.numeric STRING $1-
      /.hadd h.numeric HALTED $false
      /.hadd h.numeric SHOWN $false
      ;-- ETC add additional elements as needed

      /.signal -n $+(N.,$numeric) $1-

      if ($hget(h.numeric,HALTED)) { 
         if $debgging /echo RAW $numeric HALTED
         halt
      }
      /.hfree h.numeric
   }
}


Er anyhow you get the idea... that is if you understand the advantage of using SIGNAL events.


Beware of MeStinkBAD! He knows more than he actually does!
Joined: Jan 2004
Posts: 162
R
RRX Offline
Vogon poet
Offline
Vogon poet
R
Joined: Jan 2004
Posts: 162
Isnt it a bad idea to use an event that triggers on any raw when you only need to execute something for a small set of them?
mIRC has to trigger this combined event for all raws, and if you only need for ex 5, its giving mIRC work for nothing.

Joined: Jan 2007
Posts: 1,156
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
I dont understand the advantage of making several hash table entries and then sending info off on a signal. Seems like a ton of extra work with no advantage. No offense to you whatsoever. It's cool to see the different ways of doing things.

That goto method is so cool!!! I never thought of that.

I used to make one raw *:*:{ event with the first if and the rest elseif's. Now I use seperate events for each raw. After my events I have a raw *:*:{ for the halted raws.

I used to make $numeric a local variable but realized no reason to, so I used $numeric. On my server, Raw 0 handles all the other raws. Knock, Prop, Onjoin etc.

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Personally, using GOTO is not a good way of doing most things. Also, having everything in a single RAW, as mentioned, is wasteful if you're not handling every single RAW event.

Much better to keep them seperate. Yes, it takes a bit more space, but it is better, imo.


Invision Support
#Invision on irc.irchighway.net
Joined: Jan 2007
Posts: 1,156
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
Well I dont know about the goto thing. I just think the idea is really cool. But whether you put all raw events in one code or seperate them into single events, I dont see a huge difference.

I dont know the working of mIRC completely, but if it loads all events you have written on start, so when its a raw 352, mIRC knows you have a "raw 352:*:" event and goes right to it, then I can understand it being better than it running through if's and elseif's to get to 352.

Otherwise, whether it looks through each raw event in a script or looks through each if and elseif till it matches ... seems to be the same to me.

Joined: Dec 2002
Posts: 1,541
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Dec 2002
Posts: 1,541
well, it would certainly be faster to match :352: vs all the ifs simple because it only triggers on the one thing instead of going thru all the ifs. Think of it like this, SPEED wise it's faster to do a single comparison (each raw as their own event) than a brazillion amount of comparison checks. Ultimately, BOTH methods work, but one mthod would work better for one instance and the other method for others.


Those who fail history are doomed to repeat it
Joined: Jan 2007
Posts: 1,156
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
Well does mIRC go through all raw events to match the 352? Or does it know there is an event that is just raw 352? Would it pick this first or would it go through a raw *:*:{ in another file first?

If I have a list of seperate raw events would it go through each raw event and check to see if the $numeric matches? Or would it just go to the raw 352 one? If, on raw 352 it ignored all other raw events and only went to the one that says raw 352:*:{ then I could see how it would be not only faster, but better.

But if on every raw event, mIRC goes through each raw event you have written and checks to see if the numeric matches, then I dont see how it would make a difference if it scans all seperate events in a file, or all if's and elseif's in event. (raw *:*:)

So I'm actually asking what it does.

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Don't quote me, but I seem to recall from years back that there was some comment on how mIRC handles scripts and it was said (I think) that the events (and aliases) are loaded up so that mIRC knows they are there and does not need to read every file every time something happens. Otherwise, I'm sure we'd see some huge lag on people with many (hundreds) large scripts loaded.


Invision Support
#Invision on irc.irchighway.net
Joined: Feb 2006
Posts: 546
J
Fjord artisan
Offline
Fjord artisan
J
Joined: Feb 2006
Posts: 546
Originally Posted By: Riamus2
Don't quote me, but I seem to recall from years back that there was some comment on how mIRC handles scripts and it was said (I think) that the events (and aliases) are loaded up so that mIRC knows they are there and does not need to read every file every time something happens. Otherwise, I'm sure we'd see some huge lag on people with many (hundreds) large scripts loaded.


yes, of course this is the case :P you'll notice, for example, that changing a remote/alias file outside of mirc doesn't affect its operation until it's reloaded


"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde
Joined: Apr 2004
Posts: 759
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Apr 2004
Posts: 759
mIRC Scripts are cached that much im positive about but wheter or not that means they are parsed as well or mIRC scans its cache each time i dont know.
It would be a huge difference though.


$maybe
Joined: Jan 2007
Posts: 259
K
Fjord artisan
Offline
Fjord artisan
K
Joined: Jan 2007
Posts: 259
I would think that mIRC goes through the file each time, since if you have two events with the same matches (IE 2x 'on *:text:*:#: {'), only the first one will trigger.

Last edited by Kardafol; 23/02/07 07:07 PM.

Those who can, cannot. Those who cannot, can.
Joined: Apr 2004
Posts: 759
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Apr 2004
Posts: 759
That doesnt proof it has to go trough EACH file EACH time.
In fact we already know it doesnt go trough the files at all but trough the cached "mirrors". But even then it doesnt have to mean it reads the whole cache each time it could also map events/aliases in cache to its internal events routine thats what i was saying we dont know what mIRC does there internally.


$maybe
Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
What Kardafol is saying is that it's unlikely that mIRC would use the "stop at the first matching event per file" method if it implemented some kind of internal event lookup mechanism because there'd be no benefit to that kind of shortcut since events would be file/location transparent. It doesn't prove it, but it logically suggests that to be the case.


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Originally Posted By: Kardafol
I would think that mIRC goes through the file each time, since if you have two events with the same matches (IE 2x 'on *:text:*:#: {'), only the first one will trigger.


That would be parsing that can happen at any time. smile

Anyhow, keep in mind that Aliases are listed in the View menu. So, at least with those, mIRC knows what they are and where they are as soon as they are loaded. I wouldn't be surprised if the same is true for all other events because it wouldn't make sense otherwise.


Invision Support
#Invision on irc.irchighway.net
Joined: Jan 2007
Posts: 1,156
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
I don't agree. All this tells me is that WHEN mIRC goes through the file to log all events, it only allows one event per file. Of course I am not Khaled, (would be nice if he wouldn't mind saying a word here), but I would think that running through every line of my script on every single event would be a bit much!!

Quote:
This is what Im thinking as how it would log, like an address book:
script1.mrc
join line 43
text:hi line 66
text:bye line 67
text line 69

script2.mrc
mode line 4
raw 352 line 32
raw 311 line 40

(etc. etc.)

Aliases:
alias1 script4.mrc line 45
alias2 alias.ini line 32
alias3 script2.mrc line 56

Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Exactly. Good example. laugh


Invision Support
#Invision on irc.irchighway.net
Joined: Apr 2004
Posts: 759
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Apr 2004
Posts: 759
Originally Posted By: starbucks_mafia
What Kardafol is saying is that it's unlikely that mIRC would use the "stop at the first matching event per file" method ..


Thats like the opposite from what i gathered from:
Originally Posted By: Kardafol

I would think that mIRC goes through the file each time, since if you have two events with the same matches (IE 2x 'on *:text:*:#: {'), only the first one will trigger.

which is atleast 50% untrue since mIRC doesn't use files to begin with :P All im saying is we dont know if it uses the "stop at the first matching event in the cache " or that it parses the files while caching and mapping internal pointers to its cache.


$maybe
Page 1 of 2 1 2

Link Copied to Clipboard