mIRC Home    About    Download    Register    News    Help

Topic Options
#215738 - 04/10/09 04:51 AM /set -kuN what does it do?
Ninko Offline
Vogon poet

Registered: 29/06/04
Posts: 139
Loc: England, UK
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?

Top
#215743 - 04/10/09 06:33 AM Re: /set -kuN what does it do? [Re: Ninko]
RusselB Offline
Planetary brain

Registered: 03/08/04
Posts: 7252
Loc: Ontario, Canada
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.

Top
#215749 - 04/10/09 10:40 AM Re: /set -kuN what does it do? [Re: Ninko]
Horstl Offline
Hoopy frood

Registered: 03/11/06
Posts: 1559
Loc: Germany
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.
}

Top
#215762 - 04/10/09 08:30 PM Re: /set -kuN what does it do? [Re: Ninko]
Ninko Offline
Vogon poet

Registered: 29/06/04
Posts: 139
Loc: England, UK
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

Top
#215763 - 04/10/09 11:13 PM Re: /set -kuN what does it do? [Re: Ninko]
Horstl Offline
Hoopy frood

Registered: 03/11/06
Posts: 1559
Loc: Germany
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).

Top
#215764 - 04/10/09 11:38 PM Re: /set -kuN what does it do? [Re: Ninko]
argv0 Offline
Planetary brain

Registered: 13/10/03
Posts: 3918
Loc: Montreal, QC, Canada
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"

Top
#215766 - 05/10/09 12:44 AM Re: /set -kuN what does it do? [Re: Ninko]
Ninko Offline
Vogon poet

Registered: 29/06/04
Posts: 139
Loc: England, UK
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

Top
#215774 - 05/10/09 09:41 AM Re: /set -kuN what does it do? [Re: Ninko]
Horstl Offline
Hoopy frood

Registered: 03/11/06
Posts: 1559
Loc: Germany
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)

Top
#215778 - 05/10/09 05:53 PM Re: /set -kuN what does it do? [Re: Horstl]
Wims Offline
Planetary brain

Registered: 31/07/06
Posts: 3494
Loc: France
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

Top
#215779 - 05/10/09 06:06 PM Re: /set -kuN what does it do? [Re: Wims]
Excalibur Offline
Vogon poet

Registered: 07/05/09
Posts: 139
Loc: FL, US
-s is for status, -a is for active.
_________________________
- Excalibur
- Good and Evil, there never is one without the other.

Top
#215780 - 05/10/09 06:12 PM Re: /set -kuN what does it do? [Re: Excalibur]
Wims Offline
Planetary brain

Registered: 31/07/06
Posts: 3494
Loc: France
we're talking about /set, -s mean show and show what you've set, -a doesn't exists afaik


Edited by Wims (05/10/09 06:14 PM)
_________________________
Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net

Top
#215781 - 05/10/09 07:05 PM Re: /set -kuN what does it do? [Re: Wims]
Horstl Offline
Hoopy frood

Registered: 03/11/06
Posts: 1559
Loc: Germany
$me stands corrected wink

Top