mIRC Home    About    Download    Register    News    Help

Print Thread
#262172 08/01/18 12:34 AM
Joined: Jul 2006
Posts: 4,145
W
Wims Offline OP
Hoopy frood
OP Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
Although the very last request which leads to the new $fromeditbox talks about a $calias, which has been suggested in the past, the purpose of such a function was to report the name of the alias which called our alias (or maybe the addition of $caller has nothing to do with https://forums.mirc.com/ubbthreads.php/topics/262061/$fromeditbox ??)

$caller does not actually do that, it seems to return information about the context in which the alias was called, which is great to have too, but it's not addressing the main issue: debugging script by displaying a "stack trace".

Something else which would help a lot with debugging would be able to also get the script filename which have the alias which called our alias, as well as getting the script line.

So maybe the current $caller could see some properties (without any parameter just like $mouse!):

$caller.alias - return the name of the alias which called the current alias
$caller.script - return the filename in which the alias which called the current alias can be found
$caller.scriptline - return the line number in $caller.script where the alias which called the current alias can be found.

I'd also like to get examples for which $caller return "activex", "mouse" and "other"


Last edited by Wims; 08/01/18 01:24 AM.

#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Wims #264334 21/11/18 07:01 PM
Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
Originally Posted By: Wims

I'd also like to get examples for which $caller return "activex", "mouse" and "other"


$comcall = activex
/filter -a = other
nicklist right-click menu = other
/toolbar -a = mouse

Last edited by maroon; 21/11/18 07:52 PM.
maroon #265368 05/04/19 10:01 PM
Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
I would like to request "tabcomp" be added to the list of features currently returned by $caller. It currently returns "other". eg: type $caller then the tab key.


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Wims #266529 22/12/19 03:17 PM
Joined: Aug 2003
Posts: 319
P
Pan-dimensional mouse
Offline
Pan-dimensional mouse
P
Joined: Aug 2003
Posts: 319
Originally Posted by Wims
Although the very last request which leads to the new $fromeditbox talks about a $calias, which has been suggested in the past, the purpose of such a function was to report the name of the alias which called our alias (or maybe the addition of $caller has nothing to do with https://forums.mirc.com/ubbthreads.php/topics/262061/$fromeditbox ??)

$caller does not actually do that, it seems to return information about the context in which the alias was called, which is great to have too, but it's not addressing the main issue: debugging script by displaying a "stack trace".

Something else which would help a lot with debugging would be able to also get the script filename which have the alias which called our alias, as well as getting the script line.

So maybe the current $caller could see some properties (without any parameter just like $mouse!):

$caller.alias - return the name of the alias which called the current alias
$caller.script - return the filename in which the alias which called the current alias can be found
$caller.scriptline - return the line number in $caller.script where the alias which called the current alias can be found.

To be able to produce a stack trace, what you need in addition to properties is for $caller to be extended as follows:

$caller(0) - return the depth of the call stack
$caller(x).prop - return above details of the call from x levels higher

You could then have the following:

Code
alias FooBar {
    return $identifier
:error
    StackTrace $ $+ identifier returned an error
}

alias StackTrace {
    var %n $caller(0), %i 2
    if (%n == 1) {
        echo -s 4 StackTrace can be used to report an error and give details of how the error code was reached
        halt
    }
    echo -s 4 StackTrace: Fatal error: $1- $+ : " $+ $error $+ " occurred in $caller(1).script at line $caller(1).scriptline $+ :
    while (%i <= %n) {
        echo -s 4 StackTrace: Called as $caller(%i) $caller(%i).alias from $caller(%i).script at line $caller(%i).scriptline
        inc %i
    }
    halt
}


Unfortunately this implementation would require an error routine in every alias because if the error propagated to a higher level alias, the stack trace would be lost. However if the stack trace in $caller was copied to an extended $error identifier at the time of the error, you could then have something like the following:


Code
alias FooBar {
    Foo
:error
    StackTrace $ $+ identifier returned an error
}

alias Foo { Bar }

alias Bar { CREATEanERROR }

alias StackTrace {
    var %n $error(0), %i 2
    if (%n == 1) {
        echo -s 4 StackTrace can be used to report an error and give details of how the error code was reached
        halt
    }
    echo -s 4 StackTrace: Fatal error: $1- $+ : " $+ $error $+ " occurred in $error(1).script at line $error(1).scriptline $+ :
    while (%i <= %n) {
        echo -s 4 StackTrace: Called as $error(%i).type $error(%i).alias from $error(%i).script at line $error(%i).scriptline
        inc %i
    }
    halt
}


Link Copied to Clipboard