mIRC Home    About    Download    Register    News    Help

Print Thread
#262061 27/12/17 12:22 PM
Joined: Apr 2010
Posts: 969
F
Hoopy frood
OP Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
It would be greatly appreciated if there was an identifier that returned $true|$false dependant on if an alias was called directly from the editbox. Its been brought up before but I'd like to bring it back to your attention with a valid use-case.

I'm currently working on my theme(because mIRC customization is what its all about). In doing such, I want to override /msg, /describe, /notice, etc for display purposes.

When I don't have a respective window open for the target and ...
... the command is called from the editbox I want to display the message to the active window.
... the command is called from an alias, script, timer, menu, etc I want to display the message to the status window.

Code:
alias example {
  echo -a the example alias was called from: $iif($fromeditbox, editbox, elsewhere)
}

Only when the alias is directly called from the editbox should $fromeditbox be truthy. if AliasA calls AliasB, regardless of where AliasA was called, within AliasB $fromeditbox would return $false.

If you are interested in a more expansive solution, AdiIRC supports a $calias identifier to return various information about the caller-stack. If something similar were implemented, I'd like to see it expanded to include a way to determine the caller-type; such as 'timer', 'event', 'alias', 'menu', 'editbox', 'identifer'($hfind() for example), 'command'(/filter), etc


Last edited by FroggieDaFrog; 27/12/17 12:32 PM.

I am SReject
My Stuff
Joined: Jul 2006
Posts: 4,149
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,149
$calias was brought up again very recently actually. I agree it would be great to see this added, I would rather see $calias and something for the callertype than a $fromeditbox, which only works for one case.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Wims #262063 27/12/17 01:19 PM
Joined: Apr 2010
Posts: 969
F
Hoopy frood
OP Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
I definitely agree. But often, when people are asking for this sort of functionality its to distinguish from editbox vs. script calls so figured $fromeditbox is a simpler route Khaled could take

Last edited by FroggieDaFrog; 27/12/17 01:20 PM.

I am SReject
My Stuff
Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
Dropping this here as a reference to future historians, because it's good, and not as a critical opinion. I too suggested $calias over a decade ago.

Code:
alias fromeditbox { return $iif($event || $ctimer || $menu, $false, $true) } ; by SReject 2017


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Raccoon #262072 28/12/17 02:05 PM
Joined: Apr 2010
Posts: 969
F
Hoopy frood
OP Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
Two quick notes about my snippet raccoon posted

1. Nested alias calls will still return $true if the stack's entry point is from the editbox. This may or may not be desirable and AFAIK there's no work around to check if an alias was called directly from the editbox

2. It may be desirable to have the alias treat menu calls as if they were editbox calls (such as when determining where to display an output message). To achieve such behavior, you can remove "|| menu" from the alias or use the updated version given below.

A slightly updated version:
Code:
/*
$fromeditbox
    Returns $true if the call stack was initiated from an editbox

$fromeditbox(allowMenu)
    Returns $true if the call stack was initiated from an editbox

    If allowMenu is truthy, menu initiated calls will be treated the same as editbox calls
*/
alias fromeditbox return $iif($event || $ctimer || (!$1 && $menu), $false, $true)



Last edited by FroggieDaFrog; 28/12/17 02:14 PM.

I am SReject
My Stuff
Joined: Apr 2010
Posts: 969
F
Hoopy frood
OP Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
With the addition of $fromeditbox can we get it extended:

$fromeditbox(N)
N is a bitwise of:
1 = returns $true if the root caller is the editbox
2 = treats calls from menu the same as the editbox
(with the possibility of other options)

With the above, the following would be possible:
Code:
;; called from the editbox
alias example1 {
  example1A
}

alias example1A {
  echo -a $fromeditbox    == $false
  echo -a $fromeditbox(1) == $true
  echo -a $fromeditbox(2) == $true
  echo -a $fromeditbox(3) == $true
}

menu status {
  example2: example2
}
alias example2 {
  echo -a $fromeditbox    == $false
  echo -a $fromeditbox(1) == $false
  echo -a $fromeditbox(2) == $true
  echo -a $fromeditbox(3) == $true
  
  example2a
}
alias example2a {
  echo -a $fromeditbox    == $false
  echo -a $fromeditbox(1) == $false
  echo -a $fromeditbox(2) == $false (Not called directly from the menu)
  echo -a $fromeditbox(3) == $true
}

Last edited by FroggieDaFrog; 16/01/18 01:37 AM.

I am SReject
My Stuff

Link Copied to Clipboard