mIRC Home    About    Download    Register    News    Help

Print Thread
/set -kuN what does it do? #215738 04/10/09 03:51 AM
Joined: Jun 2004
Posts: 139
N
Ninko Offline OP
Vogon poet
OP Offline
Vogon poet
N
Joined: Jun 2004
Posts: 139
Hi there,
What does the switch -k do when using the /set command?

The manual says: The -k switch keeps the current -uN setting for a variable.

So I assumed it meant it will keep counting down even after changing the variable value, but it doesn't, eg...

Code:
set -ku30 %test123 1
%test123 = $calc(%test123 + 5)


The above stops the unset counter, so what does -k do and how can I change a variables value while keeping the unset time counting?

Re: /set -kuN what does it do? [Re: Ninko] #215743 04/10/09 05:33 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Too tired to test this right now, but I think it means that the unset time will be retained even if mIRC is closed.

Normally global variables maintain there value even if mIRC is closed.

However, I don't think the delay for the unsetting of the variable is maintained if mIRC is closed, thus a variable would not be unset after mIRC is restarted, unless the -k switch is also included.

Re: /set -kuN what does it do? [Re: Ninko] #215749 04/10/09 09:40 AM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Don't use the -k switch in the first set command (where you specify the unset time) but in your subsequent set-commands (where you assign some new value but want to keep it's unset time running).

Example:
Code:
alias settest {
  set -u5 %testX A
  ECHO -a set variable to value $var(testX,1).value $+ . unsets after $var(testX,1).secs secs.

  .timer -m 1 2500 newset
}

alias -l newset {
  set -k %testX B
  ECHO -a set variable to value $var(testX,1).value $+ . unsets after $var(testX,1).secs secs.
}

Re: /set -kuN what does it do? [Re: Ninko] #215762 04/10/09 07:30 PM
Joined: Jun 2004
Posts: 139
N
Ninko Offline OP
Vogon poet
OP Offline
Vogon poet
N
Joined: Jun 2004
Posts: 139
Code:
set -u30 %test123 1
while (5 >= %test123) {
  echo var: %test123
  set -k %test123 = $calc(%test123 + 1)
}


Why does the above code not echo 1-5 like it should? Instead it echos 1 and stops - %test123 = 2 at the end of the while loop.

Thanks


Ninko

Re: /set -kuN what does it do? [Re: Ninko] #215763 04/10/09 10:13 PM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Your problem is caused by the "="-char in your /set -k command. While the use of "=" is recommended for /var commands, it's not part of the /set -syntax (...a common pitfall).
By setting your variable to the literal value "= 2", the condition of your while statement isn't met any more and the loop stops at "= 2". smile

Code:
  set -su30 %test123 1
  while (5 >= %test123) {
    set -sk %test123 $calc(%test123 + 1)
  }
Note the -s switches (useful for debugging).

Re: /set -kuN what does it do? [Re: Ninko] #215764 04/10/09 10:38 PM
Joined: Oct 2003
Posts: 3,918
A
argv0 Offline
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
In addition to what Horstl said, your code doesn't really make sense.

set -u30 implies the variable will stay set for 30 seconds. The time starts counting *after* your script has ended, but you immediately /set -k to stop this timer, making both switches unnecessary. Since the switches are not needed you can replace the latter /set command with a much simpler /inc command which increases by optional argument N (defaulting to 1).

The proper way to loop from 1 to 5 is simply:
Code:
var %i = 1
while (%i <= 5) { echo var: %i | inc %i }


Again, I'm not sure what you're trying to do, but -u/-k will have no effect within the same alias/event; they effectively cancel each other out.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Re: /set -kuN what does it do? [Re: Ninko] #215766 04/10/09 11:44 PM
Joined: Jun 2004
Posts: 139
N
Ninko Offline OP
Vogon poet
OP Offline
Vogon poet
N
Joined: Jun 2004
Posts: 139
Hi Horstl,
Thanks for your reply, what does the -s switch do, I can't see it in the manual?

Hi argv0,
What is the -k switch for then? From what I've tested the -k switch allows you to change the variable value while keeping the unset count going, which is what I want. How does it 'stop' it?


Ninko

Re: /set -kuN what does it do? [Re: Ninko] #215774 05/10/09 08:41 AM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Like with many commands, -s in /set will echo the result to your status window.
(The helpfile lacks an explanation of -s at /set /unset /unsetall /dec and /inc; there's a brief note at /var only)

Re: /set -kuN what does it do? [Re: Horstl] #215778 05/10/09 04:53 PM
Joined: Jul 2006
Posts: 3,558
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,558
Quote:
Like with many commands, -s in /set will echo the result to your status window.
active*


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: /set -kuN what does it do? [Re: Wims] #215779 05/10/09 05:06 PM
Joined: May 2009
Posts: 139
E
Excalibur Offline
Vogon poet
Offline
Vogon poet
E
Joined: May 2009
Posts: 139
-s is for status, -a is for active.


- Excalibur
- Good and Evil, there never is one without the other.
Re: /set -kuN what does it do? [Re: Excalibur] #215780 05/10/09 05:12 PM
Joined: Jul 2006
Posts: 3,558
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,558
we're talking about /set, -s mean show and show what you've set, -a doesn't exists afaik

Last edited by Wims; 05/10/09 05:14 PM.

Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: /set -kuN what does it do? [Re: Wims] #215781 05/10/09 06:05 PM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
$me stands corrected wink