| View previous topic :: View next topic ? |
| Author |
Message |
katsklaw
Joined: 03 Nov 2004
Posts: 128
Location: irc.nfinate-irc.org
|
Posted: Sun May 15, 2005 12:45 am?? ?Post subject:
|
 |
|
| SebDE wrote: |
| Fenris_Wolf wrote: |
| I disagree with not using | ... |
Please don't start this endless discussion in an IRC related forum... Wouldn't you agree that there is enough of such discussion already elsewhere? 
|
Actually it's an IRC topic in an a thread discussing scripting tips. Meaning that the subject is completely on topic.
Secondly, not everyone has seen this topic "elsewhere".
As far as "ending the debate" .. there isn't any harm in discussing differences in views especially when it's on topic, Why else would there be a forum?
|
|
| Back to top |
|
|
eXcelsior
Joined: 11 Apr 2005
Posts: 1
|
Posted: Mon May 16, 2005 8:36 am?? ?Post subject:
|
 |
|
|
I noticed that you mentioned vars. How about not using vars? Try to nest function names, use $1...n and hash tables.
|
|
| Back to top |
|
|
Yochai
Joined: 31 Mar 2005
Posts: 5
|
Posted: Sat May 21, 2005 7:35 pm?? ?Post subject:
|
 |
|
Ok about the /var VS /set -l ....
The best thing to use in loops is actually /var .
BUT , the best way to use that is to declare the /var before the loop, and then use the %var = data syntax.
a simple alias to end the debate in this case:
| Code: |
test {
? var %ticks = $ticks
? var %a = 1
? var %check
? while (%a < 20000) {
? ? %check = test
? ? inc %a
? }
? echo -a without /var $calc($ticks - %ticks)
? var %ticks = $ticks
? var %a = 1
? while (%a < 20000) {
? ? var %check = test
? ? inc %a
? }
? echo -a with /var $calc($ticks - %ticks)
? var %ticks = $ticks
? var %a = 1
? while (%a < 20000) {
? ? set -l %check = test
? ? inc %a
? }
? echo -a with /set -l $calc($ticks - %ticks)
}
|
BUT, there is a situation where it's better to use /set -l over all others.
When you're calling an alias through a loop, or /filter command, there are sometimes when you won't be able to declare the variable beofre the loop using /var, so you'd want to use /set -l which is faster then the /var command.
For example, I have this alias for sorting an MDX list by a column:
| Code: |
Alias -l Filter-num {
? set -l %a $remove($gettok($1,2,9),$chr(32))
? set -l %b $remove($gettok($2,2,9),$chr(32))
? return $iif(%b > %a,-1,$iif(%a > %b,1,0))
} |
Note: I had to set the vars because I used them for something else in the original alias, that's why I didn't just do it all in one line.
This alias is called with /filter, so there's no where I can declare the %a and %b vars before the loop starts, so I used /set -l to set the variables.
_________________
#mirc
Undernet
|
|
| Back to top |
|
|
|
|
?
|
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
|
Powered by phpBB ? 2001, 2002 phpBB Group
Debt help management | Rome Hotels | Hotels in Lisbon | Hudson Hotel New York | Hotels in Krak?³w
|