mIRC Homepage

$Identifier that returns how deep a script is?

Posted By: KubosKube

$Identifier that returns how deep a script is? - 29/12/19 02:30 AM

I'm sorry to be blowing up the forums with so many cryptic titles lately...

I was looking for an identifier that can return how many levels a script has in it. I don't know how else to explain it, so let me show you:

Code
alias test {
  echo -a alias test was called at level $level
  test_part2
}

alias test_part2 {
  echo -a alias test_part2 was called at level $level
}


The output should look something like
Code
alias test was called at level 1
alias test_part2 was called at level 2


I just want to know if such an identifier exists. Thanks for putting up with my constant pestering!
Posted By: maroon

Re: $Identifier that returns how deep a script is? - 29/12/19 05:58 PM

Other than having a parameter passed between aliases, it would be difficult. If the alias were always called with the $1 parm being set to $calc(1+$1), the top level alias being called without a $1 parameter would be level 0. Each time the aliases see a value as $1, it's the parent's level incremented by +1. If you need the top level to be 1, then have it call the alias like $iif($1,$calc(1+$1),1)

You can search the forum for $calias to find requests for identifiers that would inform info about each level, including which line they were called from, which script, the name of the alias, whether it was local or not, etc.

$calias would be a big help with debugging scripts, because sometimes it turns out to be a problem caused by a local alias which doesn't show up when checking $isalias(name) from the editbox, or happens only when called from certain scripts or from certain lines.
© 2020 mIRC Discussion Forums