mIRC Homepage
Posted By: Ninko /set -kuN what does it do? - 04/10/09 03:51 AM
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?
Posted By: RusselB Re: /set -kuN what does it do? - 04/10/09 05:33 AM
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.
Posted By: Horstl Re: /set -kuN what does it do? - 04/10/09 09:40 AM
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.
}
Posted By: Ninko Re: /set -kuN what does it do? - 04/10/09 07:30 PM
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
Posted By: Horstl Re: /set -kuN what does it do? - 04/10/09 10:13 PM
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).
Posted By: argv0 Re: /set -kuN what does it do? - 04/10/09 10:38 PM
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.
Posted By: Ninko Re: /set -kuN what does it do? - 04/10/09 11:44 PM
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
Posted By: Horstl Re: /set -kuN what does it do? - 05/10/09 08:41 AM
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)
Posted By: Wims Re: /set -kuN what does it do? - 05/10/09 04:53 PM
Quote:
Like with many commands, -s in /set will echo the result to your status window.
active*
Posted By: Excalibur Re: /set -kuN what does it do? - 05/10/09 05:06 PM
-s is for status, -a is for active.
Posted By: Wims Re: /set -kuN what does it do? - 05/10/09 05:12 PM
we're talking about /set, -s mean show and show what you've set, -a doesn't exists afaik
Posted By: Horstl Re: /set -kuN what does it do? - 05/10/09 06:05 PM
$me stands corrected wink
© mIRC Discussion Forums