mIRC Homepage
Posted By: maroon Identifier warning from $scon().identifier - 22/02/23 06:39 AM
Through a typo, I accidentally found that, even though $scon() displays the identifier warning message, it doesn't actually halt the script, and simply returns $null for the identifier call. Happens as far back as 6.35, and these same behaviors also happen for $scid().identifier

//echo -s result: $scon(1).network * $scon(1).nosuchidentifier identifier warning should cause this echo to be halted | echo -s this shouldn't display if identifier warning is enabled

The behavior also extends to when making ilegal identifier calls inside the .identifier being called when its a scripted alias

//echo -s result: $scid(1).testingscon | echo -a error should prevent this showing

Code
alias testingscon { echo -a error: $sha1 | echo -a this should not display }

The only way I can see this being a compatibility problem is if someone thinks this is the closest we have to an $isidentifier work-around, where we can check for the existence of some identifiers by the absence of the displayed identifier warning, though it won't work for identifiers who use parenthesis because $scon() won't let you, and won't work if it gets intercepted by a scripted alias of the same name.

//echo -a $isidentifier(isadmin)

Code
alias isidentifier {
  noop $scid($cid). [ $+ [ $1 ] ]
  var %i $line(status window,0)
  var %a $line(status window,%i)
  if ($line(status window,%i) == -) { dec %i | var %a $line(status window,%I) }
  var -s %msg * no such identifier: $ $+ $1 $+ *
  if (%msg iswm %a) return $false
  return $true
}
Thanks for your bug report. The source code for $scon()/$scid() has a somewhat cryptic "do not propagate errors" comment with no explanation. I am guessing that when it was added in 2002, the scripters at the time asked for this. As you know, I generally will not make changes to features that have worked in a particular way for a long time, as it could break backward compatibility, so this behaviour has to stay in place.
Ah - hindsight is definitely a wonderful thing.
© mIRC Discussion Forums