ON *:INPUT:*:     { double_dollar $1- }
ON *:TEXT:test *:*:{ double_dollar $1- }

alias double_dollar {
  var %last $gettok($1-,-1,32) , %nextlast $gettok($1-,-2,32)
  if ((% isin %last) || ($ isin %last) || (*test !iswm %nextlast) ) return
  echo 3 -ag begin event: $event $chr(22) chan: $chan $chr(22) last: %last $chr(22) $ $+ %last $+ : [ $~ $+ [ %last ] ] $chr(22) script: $script $asctime

  if (%last isalpha) {
    echo 5 -ag event: $qt($event) next line echoing $qt($ $+ $ $+ %last) where $ $+ %last is $qt( [ $~ $+ [ %last ] ] ) chan: $chan
    echo 5 -ag %last $+ : [ $ $+ $ $+ [ %last ] ]
  if (%last ==     left0) echo 5 -ag scriptline: $scriptline    left0: $$left(foo,0)
  if (%last ==   gettok1) echo 5 -ag scriptline: $scriptline  gettok1: $$gettok($active,1,32)
  if (%last ==   gettok2) echo 5 -ag scriptline: $scriptline  gettok2: $$gettok($active,2,32)
  echo 4 -ag  reached end event: $event script: $script

#double_dollar_chan off
alias chan { echo -a fake alias to prevent $ $+ $ $+ chan identifier warning within :input: $scriptline | return fakechan }
#double_dollar_chan end

On further testing, the $$local_identifier failure issue seems related to an issue where $~local_identifier is always no-such-identifier, even when the local identifier is defined as a not-null string. With the above script loaded, type the command:

/double_dollar test event

It executes the alias twice, first within input where event=input, then again where event=$null as part of the editbox command. In both cases, $$event generates the no-such-identifier warning, even though it is defined within INPUT. The message above the error line falsely reports $event is $null within INPUT because that line is using single dollar for $~event and I can't find a local identifier where the local identifier has a string value and the $~ form is the same value.

$$event should generate the identifier warning error only for the 2nd execution that's outside the INPUT event, where $event doesn't exist as an identifier.


Now have 2 clients in a channel using the example code, and have one of them paste these 2 commands into #channel:

test chan
test nick

For the typist, 'test chan' and 'test nick' within ON INPUT both generate the identifier warning for $$chan and $$nick respectively

For the viewer, both commands within ON TEXT generates a /return and not an identifier warning, as if $chan and $nick exist but both have $null string value.

It's correct for the typist to get an identifier warning for $$nick since that local identifier isn't defined for the INPUT event.

Within INPUT, the typist should not get an identifier warning for $$chan unless typed somewhere like the status window or a query window where $chan isn't a valid identifier. Because $chan is defined in a #channel editbox, $$chan should not /return or generate a warning.

For the viewer, neither of these commands should generate that /return and should continue to echoing the red message last line of the alias. $chan and $nick are both defined in ON TEXT, so $$chan and $$nick should both be the same values as $chan and $nick. ON TEXT should trigger the /return for $$chan only within the viewer's query window event where $chan is $null.

After enabling the 2nd alias with: //enable #double_dollar_chan | saveini

... the identifier warning does not get triggered for either the typist or viewer, and the typist correctly has the fake_chan value returned if they type a command in the status window or a query window. However for both typist's INPUT and viewer's TEXT events within a channel window, $$chan is incorrectly seeing 'alias chan' instead of using the actual value of $chan. Within TEXT, the presence of 'alias chan' within the viewer's script changes the behavior of $$chan from being an internal identifier defined as $null generating /return instead of an identifier warning, into now being not an internal identifier and instead allowing the viewer's client to see 'alias chan'.