mIRC Homepage
Posted By: 5618 combining two aliases; the use of /scon - 27/12/08 05:09 PM
Right now I have this...
Code:
;==========================================================================================
;====== An alias called by a timer to echo the date to all channels after midnight ========
;==========================================================================================
alias datestampchans {
  var %scon = 1
  while ($scon(%scon)) {
    scon %scon datestampchans2
    inc %scon
  }
  .timerdatestamp -o 00:00 1 1 datestampchans
}
alias -l datestampchans2 {
  var %chan = 1
  while ($chan(%chan)) {
    echo -gt $v1 ---- Date switching to $date ----
    inc %chan
  }
}
;==========================================================================================

I was wondering if I can insert the local alias into the global one.
I'm not sure how to use a multi-line script after a /scon command, so I settled for calling an alias each time. Of course it works as it is, but one has to wonder.

Also, I know I can run the timer continously after 24*60*60 seconds, but this is (imo) more accurate and maybe less resource intensive.
Posted By: Wims Re: combining two aliases; the use of /scon - 27/12/08 05:29 PM
Try :

Code:
alias datestampchans {
  var %scon = $scon(0)
  while (%scon) {
    scon %scon
    var %chan = $chan(0)
    while (%chan) {
    echo -gt $chan(%chan) ---- Date switching to $date ----
    dec %chan
    }
    dec %scon
  }
  scon -r
}

And then use //.timerdatestamp -o 00:00 1 1 datestampchans

Posted By: 5618 Re: combining two aliases; the use of /scon - 27/12/08 06:06 PM
Ah yes, I can of course just use /scon N without commands to set the connection. Silly me. ;D

Funny to see how you approach it vs me. /dec and /inc, the switch of identifier and var in the while-loop, etc. wink

Also, while I (think I) see the use of /scon -r, I don't see a difference when not using it. When I leave out /scon -r, in both your script and mine (yours ends at scon 1 and mine at $scon(0)) the timer is set on scon 1 (the connection on which I initiate the alias).
Posted By: Wims Re: combining two aliases; the use of /scon - 27/12/08 06:25 PM
Quote:
Funny to see how you approach it vs me. /dec and /inc, the switch of identifier and var in the while-loop, etc.
It's a matter of habits, but it take less time to not let mirc re-evaluate each time the value of $ident in the while, and it take less chars.

I'm not really familiar with /scon -r, I've used it here to be safe or something like that smile .
Where do you run the timer command ? If it is in the code and before the /scon -r, i think it should be set on the last scon 'used', i'm not sure.
Posted By: 5618 Re: combining two aliases; the use of /scon - 27/12/08 06:33 PM
Originally Posted By: Wims
[quote]Where do you run the timer command ? If it is in the code and before the /scon -r, i think it should be set on the last scon 'used', i'm not sure.

Like I said: I call the alias from the status window of scon 1 and I leave out /scon -r. The timer is started at the end of the script, so where you had placed /scon -r.
Posted By: Wims Re: combining two aliases; the use of /scon - 27/12/08 07:40 PM
I'm not sure about your final code, if it's :
Code:
alias datestampchans {
  var %scon = $scon(0)
  while (%scon) {
    scon %scon
    var %chan = $chan(0)
    while (%chan) {
    echo -gt $chan(%chan) ---- Date switching to $date ----
    dec %chan
    }
    dec %scon
  }
  .timerdatestamp -o 00:00 1 1 datestampchans
}

This is my version, so as you said, the last value of %scon is 1 here, the timer will be run on scon 1, but with your version, the last value of %scon is $scon(0) and the timer is run from this scon.So if you're using your version, the timer is set on scon $scon(0), and not scon 1 (I've tested.)
If you're checking on which scon the timer is set on, try to don't use echo -a in your test if you use it, rather echo -s.
Posted By: 5618 Re: combining two aliases; the use of /scon - 27/12/08 07:48 PM
Actually, I simply checked which scon it was set on by looking at the $network listed in /timers...
Posted By: Wims Re: combining two aliases; the use of /scon - 28/12/08 01:57 AM
I'm not sure what's happening to you or what you're really doing, but scon -r simply reset the active connexion to what it was at the begining of the actual called routine, so if you don't use scid -r in your script after using /scon or /scid, the active connexion is the last you've used.
Code:
alias just_to_be_clear {
  scon 2
  .timer -o 1 1 echo -s this timer is associated with the connexion 2 : $!network - $!server
  scon 1
  .timer -o 1 1 echo -s timer is associated with the connexion 1 : $!network - $!server
  echo -a this command is executed on scon 1 : $network - $server
  scid -r
  ;here the active connexion is set to what it was when you called the alias
}
I just want to say that when you were saying that the timer (used instead of the /scon -r) was set on scon 1 in your version (which ends at scon $scon(0)), it's not possible.
Posted By: 5618 Re: combining two aliases; the use of /scon - 28/12/08 07:41 AM
Haha, had a bit of small spam last night.
The start time for the timer does not see or accept seconds. So during the minute of 00:00 the alias got called about 27 times.
Simply putting the timer itself on a 60-second delay timer fixes that though. grin
© mIRC Discussion Forums