mIRC Home    About    Download    Register    News    Help

Print Thread
/load handling for more than 1 filename #80735 26/04/04 04:32 PM
Joined: Mar 2003
Posts: 187
S
Soul_Eater Offline OP
Vogon poet
OP Offline
Vogon poet
S
Joined: Mar 2003
Posts: 187
Currently, it works like this:

/load -rs myscript.mrc

I'm suggesting:

/load -rs myscript.mrc,myscript2.mrc,myscript3.mrc

etc. So one could load more than 1 script. Thats my suggestion.

Re: /load handling for more than 1 filename #80736 26/04/04 05:36 PM
Joined: Feb 2004
Posts: 2,019
FiberOPtics Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Hi,

good suggestion, even though it's easy to script doesn't mean it wouldn't be even easier and convenient for it to be possible to load multiple scripts in a single command with an internal alias.

Greetz


Btw for those wondering how it could be scripted:
Code:

alias loadall { tokenize 44 $1- | var %x = $0 | while %x { load -rs $ [ $+ [ %x ] ] | dec %x } } 

Usage: /loadall script1.mrc,script2.mrc,....


Gone.
Re: /load handling for more than 1 filename #80737 26/04/04 06:22 PM
Joined: Mar 2003
Posts: 187
S
Soul_Eater Offline OP
Vogon poet
OP Offline
Vogon poet
S
Joined: Mar 2003
Posts: 187
yeah im just saying it would be nicer and easier if the internal alias was able to handle more than 1 filename.

Re: /load handling for more than 1 filename #80738 26/04/04 06:23 PM
Joined: Feb 2004
Posts: 2,019
FiberOPtics Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
I know..I'm saying the same...that alias wasn't meant for you, as I know you can script it easily :tongue:

Greetz


Gone.
Re: /load handling for more than 1 filename #80739 26/04/04 07:23 PM
Joined: Aug 2003
Posts: 325
W
Wolfie Offline
Fjord artisan
Offline
Fjord artisan
W
Joined: Aug 2003
Posts: 325
Code:
alias load { tokenize 44 $iif(-* iswm $1,$1,-rs $1) $2- | while ($0 > 1) { !load $1 $2 | tokenize 44 $1 $3- } }


Wouldn't that work?

Re: /load handling for more than 1 filename #80740 26/04/04 08:00 PM
Joined: Feb 2004
Posts: 2,019
FiberOPtics Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Hi,

I specifically stated for those wondering how it could be scripted

meaning:

1) Only meant for people who do not know how it could be scripted (all the people who have posted so far DO know how lol)
2) Not the only solution, but one of the possible ones.

Yea, that works as well, and it's expanded to any flag, so it's even better :tongue:

Edited
Code:
 
alias load {
  if ($1 !isin -a -ps -pc -pq -pn -pm -ru -rv) { echo -a Incorrect flag -> Possible flags: -a -ps -pc -pq -pn -pm -ru -rv | return }
  tokenize 44 $1-
  var %x = $0
  while (%x > 1) { !load $1 $ [ $+ [ %x ] ] | dec %x }
} 


Btw I like the way you used a 'tokenized' way to loop...that's new to me, I always use vars.

Greetz

Last edited by FiberOPtics; 26/04/04 09:03 PM.

Gone.
Re: /load handling for more than 1 filename #80741 26/04/04 08:53 PM
Joined: Aug 2003
Posts: 325
W
Wolfie Offline
Fjord artisan
Offline
Fjord artisan
W
Joined: Aug 2003
Posts: 325
Code:
alias load {
  if ( -* iswm $1 && !$istok(-a -ps -pc -pq -pn -pm -ru -rv,$1,32) && -rs* !iswm $1 ) { echo $color(info).dd -a Incorrect flag!  For more assistance type /!help /load | return }
  tokenize 44 $iif(-* iswm $1,$1,-rs $1) $2-
  while ($0 > 1) { !load $1 $2 | tokenize 44 $1 $3- }
}
There are more options than what you listed laugh

I hate to use %'s because it could cause conflict since people constantly use common % names and obviously you don't want to start making complicated names laugh

Re: /load handling for more than 1 filename #80742 26/04/04 09:01 PM
Joined: Feb 2004
Posts: 2,019
FiberOPtics Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Hi,

ah yeah now that u mention it, i only took the ones that were actually used in the examples (silly me).

Regarding those vars:
I mean that i use vars in while loops (local variables) so that will never interrupt with whatever global variables
there are set. I wouldnt be so crazy to use a global variable to loop, as it is extremely slow.

Cya



Gone.
Re: /load handling for more than 1 filename #80743 26/04/04 11:16 PM
Joined: Jan 2003
Posts: 2,523
Q
qwerty Offline
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
A bit off-topic, but I'd like to clarify this:
Quote:
I wouldnt be so crazy to use a global variable to loop, as it is extremely slow.


Not really. The output of this:
//var %t = $ticks | set %a 50000 | while %a { dec %a } | echo -s $calc($ticks - %t)

is only a few msecs bigger than this:
//var %t = $ticks | var %a = 50000 | while %a { dec %a } | echo -s $calc($ticks - %t)

Global variables are only a tiny bit slower than local vars in loops (even if the Variables list contains many variables; this seems to matter in other cases). Of course, local variables are still far more suitable for such things as loops.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Re: /load handling for more than 1 filename #80744 27/04/04 12:52 AM
Joined: Feb 2004
Posts: 2,019
FiberOPtics Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Hi,

I don' t even need to benchmark the speed of local vars vs global vars. Sure in this example where its only 1 global variable and only decreasing it. But its a whole other thing if you have 5 vars in a loop where they all are set to a differnt value with each iteration.

When using loops its not just for while %x dec %x...there can be many vars involved, many vars set to different values for each iteration. Of course I don' t need to tell you this, as far as programming goes, you're most likely x number of times better than me (I actually rarely script with the exception of the RPG bot i made, and some little snippets to help people). Imo using global vars instead of local vars in a loop slows scripts down noticeably without even benchmarking.

Note that I said: I wouldnt be so crazy to use a global variable to loop. I have probably given the impression that i was referring to the iteration variable, but i simply mean the usage of global variables vs local variables where global variables arent needed, in performing a loop.

Here's for example the alias that i use in my rpg bot:
Code:
alias addstats {

  ; Usage: /addstats nick 1 20 3 40 ... OR  /addstats nick = 1=20=5=son goku=14=...
  ; Reason for second option: text which contains spaces

  var %nick = $h.enc($1)
  var %stats = $hget(stats,%nick)
  var %locate, %value, %f.value, %l.value
  var %chr = $iif($2 == =,61,32)
  var %line = $iif($2 == =,$3-,$2-)
  var %x = $numtok(%line,%chr)

  tokenize 61 %stats  

  while (%x) {

    %locate = $gettok(%line,$calc(%x - 1),%chr)
    %l.value = $gettok(%line,%x,%chr) 
    %f.value = [ [ $+($,%locate) ] ]

    if (%locate isnum 2-13) || (%locate == 20) || (%l.value == DEAD) || (%f.value == DEAD) { %value = %l.value | goto next }
    else %value = $calc(%f.value + %l.value)   

    if (%value < 0) %value = 0
    elseif (%locate == 16) && (%value > 100) %value = 100
    elseif (%locate == 17) && (%value > 400) %value = 400
    elseif (%locate == 1) %value = $zeropad(%value)

    :next
    %stats = $puttok(%stats,%value,%locate,61)
    dec %x 2
  }
  hadd stats %nick %stats
}  


Now change all the local vars to global vars, and then benchmark it.

Note that I really don't want to begin any sort of flame in the global vs local vars.
Matter of fact, I'll let you have the last word in this thread, as I won't reply.

Greetz

Edit: since being on these mirc msg boards, I more than ever realize that its very important to express oneself in the clearest way. Any words or sentence constructions used in a way that can be interpreted in different ways, will most likely always be interpreted in the other ways than intended. I'll have to be very careful with this, as I think that is what happened here. Nevertheless, I think it's fun helping people, and even going into discussion wiht other people (as long as its civilized), as it is good learning experience and well..earth would be a rather boring place if everyone thought the same thing.


Last edited by FiberOPtics; 27/04/04 01:45 AM.

Gone.
Re: /load handling for more than 1 filename #80745 27/04/04 01:08 AM
Joined: Aug 2003
Posts: 325
W
Wolfie Offline
Fjord artisan
Offline
Fjord artisan
W
Joined: Aug 2003
Posts: 325
I go by an easier way of thinking...

Use what works. smile

Maybe I missed something here but...

If you use a local %, then if there is a global with the same name, wouldn't it affect that?

Re: /load handling for more than 1 filename #80746 27/04/04 01:15 AM
Joined: Feb 2004
Posts: 2,019
FiberOPtics Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Nope,

the values will not be mixed up.

So if you have a global variable %x 5
and in some script you use: var %x = 1, then everything will process as it should. The local vars are seperate from the global vars.

That's why they arent messy at all in using loops, as they don't interfere with the global variables.
Local variables are variables that exist only for the duration of the script in which they are created
and can only be accessed from within that script.

Oh btw, I didn't think that the way you do it was bad (with the tokenizing), as a matter of fact I even
said that I liked it, and that i hadn't seen it done like that before. Just as clarification smile

Greetz


Gone.
Re: /load handling for more than 1 filename #80747 27/04/04 01:29 AM
Joined: Aug 2003
Posts: 325
W
Wolfie Offline
Fjord artisan
Offline
Fjord artisan
W
Joined: Aug 2003
Posts: 325
Oh heck I saw that you said that..

Just that I completely overlooked the bit about local variables. That just simplified my scripting in a MAJOR way. grin

I had always thought that %x was %x no matter what. But now that I know.. I can be evul.

But I do tend to try to use $'s as much as possible.. But with this new bit of knowledge, I can relax some on my strict usage of it.

* Wolfie stands by his statement that you learn something knew everyday.

Re: /load handling for more than 1 filename #80748 27/04/04 01:38 AM
Joined: Feb 2004
Posts: 2,019
FiberOPtics Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
I second that statement, since it's so true. laugh

or perhaps even more this one: You're never too old to learn something new.

And the good thing is that it applies to anyone..even the most experienced/smartest/whatever

Greetz


Gone.
Re: /load handling for more than 1 filename #80749 27/04/04 01:59 AM
Joined: Aug 2003
Posts: 325
W
Wolfie Offline
Fjord artisan
Offline
Fjord artisan
W
Joined: Aug 2003
Posts: 325
I like the idea of K.I.S.S. but at the same time, keeping things self-contained and independant. I'd like to see our friend program mIRC while using the K.I.S.S. method. grin

The idea that I posted for a replacement "/load" command is an idea that I've been using for awhile. I actually have a script made so that when I load mIRC, I can connect to multiple networks, that I choose at that time, by typing /conns <name1> <name2>...<namexxx>
Wham, connects me to all of them, the first one being with the first status window I have open. No need to count, no need to increment and compare values. Just loop with "/server -m" until no more are left laugh

Re: /load handling for more than 1 filename #80750 27/04/04 11:10 AM
Joined: Jan 2003
Posts: 2,523
Q
qwerty Offline
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
I don't think any of us wants to start a flame war or anything. My intention is only to clear things up regarding the speed of global vs local vars. And this is NOT about persuading you or anybody else to use global vars in loops, I already said it's not the way to go. The reason I generally bother is the tendency of many, even experienced, scripters to take certain things for granted and to believe and amplify 'rumors' about the performance of various scripting items (I've been guilty of that myself as well). Also note that even though I'm replying to you, I don't do it just for you to read; I hope other people do too and learn something from it.

Take this case, for example. It is generally believed that "GLOBAL VARIABLES = SLOW". This statement is true if we are talking about global vars compared to hash tables (even this is questionable in some cases!). Adding 10000 items in a hash table is much much faster than setting 10000 global vars. But the above statement is not true if the comparison is between global vars and local vars. Creating 10000 local vars is only slightly faster than creating 10000 global ones. Yet, I've heard scripters saying they won't use global variables in on HOTLINK events because they are too slow!

I can't benchmark your /addstats alias, as it contains custom identifiers and other stuff that could corrupt the results of the benchmark, but I tested a similar set of aliases:
Code:
alias testvars1 {
  var %t = $ticks
  %a = 10000
  while %a {
    %b = %a
    %c = %b
    %d = %c
    %e = %d
    %f = %e
    %g = %f
    %h = %g
    %i = %h
    %j = %i
    dec %a
  }
  echo -s testvars1: $calc($ticks - %t)
}
alias testvars2 {
  var %t = $ticks
  var %a = 10000
  while %a {
    var %b = %a
    var %c = %b
    var %d = %c
    var %e = %d
    var %f = %e
    var %g = %f
    var %h = %g
    var %i = %h
    var %j = %i
    dec %a
  }
  echo -s testvars2: $calc($ticks - %t)
}
alias testvars3 {
  var %t = $ticks
  var %a = 10000, %b, %c, %d, %e, %f, %g, %h, %i, %j
  while %a {
    %b = %a
    %c = %b
    %d = %c
    %e = %d
    %f = %e
    %g = %f
    %h = %g
    %i = %h
    %j = %i
    dec %a
  }
  echo -s testvars3: $calc($ticks - %t)
}
You may be surprised (assuming that you care :tongue:) to see that all 3 aliases are very close together (performance-wise) and that /testvars2 is the slowest of the 3, with /testvars3 being the fastest.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Re: /load handling for more than 1 filename #80751 27/04/04 12:13 PM
Joined: Dec 2002
Posts: 2,962
S
starbucks_mafia Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
Quote:
/load -rs myscript.mrc,myscript2.mrc,myscript3.mrc

What happens when I want to load my script file "c:\myscript.mrc,myscript2.mrc,myscript3.mrc".

I think a better way to separate them is to use spaces so you have something like:
/load -rs myscript.mrc "C:\program files\mirc\myscript2.mrc" myscript3.mrc


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Re: /load handling for more than 1 filename #80752 28/04/04 02:18 AM
Joined: Aug 2003
Posts: 1,831
I
Iori Offline
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
A problem, commas are valid in both filenames and paths.

Re: /load handling for more than 1 filename #80753 28/04/04 02:34 AM
Joined: Aug 2003
Posts: 325
W
Wolfie Offline
Fjord artisan
Offline
Fjord artisan
W
Joined: Aug 2003
Posts: 325
So are spaces.
Suppose this could work:
/load script1.mrc:script2.mrc:etc

grin