mIRC Home    About    Download    Register    News    Help

Print Thread
check to see where the alias lies #209023 03/02/09 12:56 PM
Joined: Oct 2005
Posts: 827
P
pouncer Offline OP
Hoopy frood
OP Offline
Hoopy frood
P
Joined: Oct 2005
Posts: 827
$isalias(test_alias) returns $true

but how can i get the pathname to the mirc script where this alias lies? can mirc allow us to do this?

Re: check to see where the alias lies [Re: pouncer] #209024 03/02/09 01:17 PM
Joined: Jan 2007
Posts: 1,156
D
DJ_Sol Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
$isalias(name)

Returns $true if the specified name is an alias command that exists in your aliases or scripts.



Properties: fname, alias



$isalias(join) returns $true if you have an alias for /join

$isalias(join).fname returns the filename in which the alias exists

$isalias(join).alias returns the alias definition for /join


Re: check to see where the alias lies [Re: pouncer] #209025 03/02/09 01:18 PM
Joined: Feb 2003
Posts: 3,432
S
sparta Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
I found this code for you. But you cant have space in the foldername where mirc is located..

Code:
alias findalias {
  ; no such custom alias
  if (!$isalias($1).fname) { echo -a Found no such alias $qt($1) $+ . }

  ; if the custom alias is in a "aliases file": return only the matching filename
  else { 
    var %file = $isalias($1).fname, %nr = 1
    while ($alias(%nr)) {
      if (%file == $v1) {
        echo -a Found alias $qt($1) in alias-file $qt(%file) $+ . As this is no remote, cannot find the exact line anyway.
        return
      }
      inc %nr
    }

    ; if the custom alias is in a "remote file": find the alias and its line number by filtering that remote file 
    var %w = @alias.filter
    window -h %w
    filter -gfwcn %file %w $+(/(alias|alias\s+-l)\s+,$1,\s+/i)

    if ($line(%w,1)) {
      var %line = $v1, %nr = $gettok(%line,1,32), %alias = $gettok(%line,$iif(($gettok(%line,3,32) == -l),2-4,2-3),32)
      echo -a Found $qt(%alias) at line %nr of file $qt(%file)
    }
    else { echo -a Found alias $qt($1) in remote-file $qt(%file) $+ . Cannot find the exact line anyway. }

    window -c %w
  }
}


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Re: check to see where the alias lies [Re: sparta] #209031 03/02/09 01:45 PM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
$isalias(aliasname).fname works well for global aliases in remote- and "aliases" files; the code above was an approach to find local aliases and respective line numbers.
The "spaces issue" should be fixed by adding a $qt arround %file in the line "filter -gfwcn %file ..." smile

Last edited by Horstl; 03/02/09 01:48 PM.
Re: check to see where the alias lies [Re: pouncer] #209097 04/02/09 01:40 AM
Joined: Sep 2005
Posts: 2,881
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
Maybe next time you find an alias like $isalias, you should just quickly check the help file to see if it has any properties that might do what you want.

It's like discovering /echo in the help file, and then asking if there's any way to display a timestamp when you echo text.

Just do a little research and you'll save everyone, most of all yourself, some time.

Re: check to see where the alias lies [Re: pouncer] #209184 06/02/09 02:52 AM
Joined: Feb 2003
Posts: 106
L
lerpicus Offline
Vogon poet
Offline
Vogon poet
L
Joined: Feb 2003
Posts: 106
I have written a script which lists all aliases used by mirc into a custom listbox.

Double clicking on an alias within the listbox opens up the containing file and takes you to the line within that file that contains the alias definition.

Give me a yell if you think it would be useful to you.



-
Just because it never happened doesn't mean it isn't true.