mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Nov 2003
Posts: 25
N
NeoN Offline OP
Ameglian cow
OP Offline
Ameglian cow
N
Joined: Nov 2003
Posts: 25
Consider this code:
Code:
alias v1test {
  if (1 != 2) {
    echo -ag test1a: $v1 $v2
    var %dummy = $customid
    echo -ag test1b: $v1 $v2
  }
}

alias customid {
  if (3 != 4) {
    echo -ag test2: $v1 $v2
  }
  return $true
}


/v1test results in:
Code:
test1a: 1 2
test2: 3 4
test1b: 3 4


I'd find it more useful if $v1 and $v2 behaved like local vars, ie their scope is limited to the alias or script they are executed in. In that case the example would result in:
Code:
test1a: 1 2
test2: 3 4
test1b: 1 2


That way the code for v1test is independent of whatever happens in customid.

Or does anyone use these identifiers to get info from other aliases? Maybe i'm just missing something...

Joined: Apr 2004
Posts: 871
Sat Offline
Hoopy frood
Offline
Hoopy frood
Joined: Apr 2004
Posts: 871
I agree, that would make more sense AND remove a class of very hard-to-trace problems; e.g. just the other day I was helping someone who wondered why $ifmatch had some weird unexpected value, only to discover that he had a custom /msg alias... Nice suggestion!


Saturn, QuakeNet staff
Joined: Jul 2003
Posts: 77
B
Babel fish
Offline
Babel fish
B
Joined: Jul 2003
Posts: 77
i agree in full it really doesnt make sense why it would be global...


hmmm signed by me
Joined: May 2003
Posts: 79
A
Babel fish
Offline
Babel fish
A
Joined: May 2003
Posts: 79
It seems like $v1/$v2 stays with their latest global value, which can be useful in some cases, but are really problematic when you're coding and you just don't know where the error is to find out it was the local/global problem. Good suggestion there.

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Quote:
I'd find it more useful if $v1 and $v2 behaved like local vars, ie their scope is limited to the alias or script they are executed in.
That way the code for v1test is independent of whatever happens in customid.
Or does anyone use these identifiers to get info from other aliases? Maybe i'm just missing something...



Agreed however not using $v1 & $v2 maybe $lv1 $lv2. Since the nature of $v1 & $v2 is already known, changing it would cause (some) scripts to fail.

And yes, I have used these to return values to the calling alias,although I could have done other things this seemed easiest at the time, for what i was doing.
heres an example of one i made.
Code:
alias nicks.channels.condition.cmd.failcmd {
  var %i = 1
  while (%i <= $numtok($1,32)) {
    var %l = 1
    while (%l <= $numtok($1,32)) {
      if ( $gettok($1,%i,32) $3 $gettok($2,%l,32) ) {
        return $4
      }
      inc %l
    }
    inc %i
  }
  return $iif($5,$5,.echo -q . $(|,) ;) $iif($null = $null,)
}


could be used like this
$nicks.channels.condition.cmd.failcmd(Dave DaveC Davo,#mirc #mircnet #blah,ison,msg,halt) $v2  $v1  Found ya finally! See my PM please.
!msg $v1 I wanted to talk to you about blah blah blah

Joined: Jul 2003
Posts: 77
B
Babel fish
Offline
Babel fish
B
Joined: Jul 2003
Posts: 77
true wish this bug would have been discovered sooner but it should be a $lv1 cause as you said some scripts might bank on the current implementation.. so as you said maybe a $lv1 and $lv2 would be a good idea as it makes more sense and allows the use of a global id and a local id


hmmm signed by me
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
I dont know if i would call it a bug, since i would have to say all other $identifiers i can think of are global, so $v1 and $v2 being global would seem to be in line with this. Also $ifmatch has had the same behavour as current $v1 $v2 so it has been known just something thats not overly clear. Also the help file only says its from a IF THEN ELSE construct, it makes no mention of $IIF or WHILE results also effecting them. frown


Link Copied to Clipboard