mIRC Homepage
Posted By: Nightstorm prob with /alias - 26/05/09 12:26 AM
hi,
If I enter this in the Remotes section in the editor, all works proper...i.e the alias F7 gets added to the Aliases section, like....F7 b >.
Code:
alias ftest2 {
  set -u0 %fkey F7
  alias %fkey b >
}


but if i try to add a multiline alias like, below.. then instead of adding the alias F7 to the alias' section it executes the line..... b >

Code:
alias Ftest {
  set -u0 %fkey F7
  alias %fkey {
    if (!$istok(channel query chat,$window($active).type,32)) halt
    b >
  } 
}


the following part is aside from the main prob described above but I thought I'd just mention also that originally specifying a variable name as the alias (in the remotes section) didn't work like :

set %fkey f7

alias %fkey {

}

- - - - - - - -
Thankyou
Posted By: RusselB Re: prob with /alias - 26/05/09 02:35 AM
Give this a try
Code:
alias Ftest {
  set -u0 %fkey F7
  alias %fkey {
    $iif($istok(channel query chat,$window($active).type,32),b >)
  } 
}

Sometimes changing the order of a set of events allows a script to work, event though the logic for both methods is similar.

Regretfully I'm not currently in a location where I can access mIRC to test this.
Posted By: Horstl Re: prob with /alias - 26/05/09 03:53 AM
Quoting the helpfile:
Quote:
/alias [filename] <aliasname> <command>
Adds, removes, replaces aliases; it is limited to single line aliases and will not affect multiple line definitions.

Thus this will work:
Code:
alias Ftest {
  set -u %fkey F7
  alias %fkey if ($istok(channel query chat,$window($active).type,32)) <single line of commands to execute if the condition is true>
}


As you can create only single-lined aliases with the /alias command, you have to use pipes instead of newlines for more complex functions. And as the pipe-char is evaluated once (as part of the code of the "alias-setting" alias), you have to prevent the evaluation of the pipe, with either:
Code:
alias setaliastest1 {
  alias Testalias1 <command1> $chr(124) <command2> $chr(124) <command3>
}

Or:
Code:
alias setaliastest2 {
  alias Testalias2 <command1> $(|,0) <command2> $(|,0) <command3>
}

If curly brackets are unavoidably required, you have to escape them as well. Example:
Code:
alias setaliastest3 {
  alias Testalias3 if (%x < 3) $({,0) <some code> $(},0) $(|,0) else $({,0) <some other code> $(},0) 
}

But, if you only try to assign a "fixed" function to a variable F-Key, why not put the function in a fixed alias and have the fkey call this alias? It'll be more clear, therefore more easy to write and debug. The last example above is an alias with only two condition-command pairs, and it's already a mess laugh. Example:
Code:
alias AssignFkey {
  set -u %fkey F7
  alias %fkey myfixedfunction
}

alias myfixedfunction {
  ---- code as usual ---
}

Posted By: Nightstorm Re: prob with /alias - 26/05/09 04:36 AM
RusselB, this is what i tried, - it doesn't (work) get added to the aliases section. [maybe cause it expects a command after /alias]
Code:
alias Ftest {
  set -u0 %fkey F7
  alias %fkey $iif(!$istok(channel query chat,$window($active).type,32),b >)
}


thx
Posted By: Horstl Re: prob with /alias - 26/05/09 04:45 AM
This is again caused by the evaluation I tried to describe above. It will work with:

$!iif($istok(channel query chat,$window($active).type,32),b >)

Note the extra exclamation mark, to prevent the evaluation of the iif inside the "Ftest" alias itself. And because you want to have b > executed if the window is either channel query or dcc chat, use $istok instead of !$istok
Posted By: Nightstorm Re: prob with /alias - 26/05/09 05:22 AM
Horst, in reply to your first post..the earlier methods , with the char-codes & escapments would be unfeasable , but the explanation was very enlightening & it was interesting to know how it works & what was actually happening there.

horst wrote..
Quote:
But, if you only try to assign a "fixed" function to a variable F-Key, why not put the function in a fixed alias and have the fkey call this alias?..

dunno if i understood you right, but i figured that means , like splitting my original Alias in 2 parts, & adding another alias in the chain. This is what I tried :
Code:
alias Ftest {
  set -u0 %fkey F7
  alias %fkey Ftest3
}

alias Ftest3 {
  if (!$istok(channel query chat,$window($active).type,32)) halt
  b >
}

I get F7 Ftest3 in my Alias section
It Works!! : )
and i can add as many commands to the Alias that way

Also ..
Code:
$!iif($istok(channel query chat,$window($active).type,32),b >)
works fine, & that would come in use for me in certain places..& save me the trouble of adding another alias

Thanks a Lot ! !
-


Posted By: RusselB Re: prob with /alias - 26/05/09 06:09 AM
You're quite welcome.

I knew I was close, but, as I said, I couldn't test at that time.
© mIRC Discussion Forums