mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 2 1 2
$alias(FILE).total #230274 03/03/11 02:33 PM
Joined: Dec 2008
Posts: 1,511
westor Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,511
Hello,

I wanna suggest an identifier to return how much aliases are in a "test.mrc" .

e.g: $isalias(test.mrc).total or $alias(test.mrc).total

NOTE: I don't know if there is an way to do this but an alias will be helpfull

Re: $alias(FILE).total [Re: westor] #230292 03/03/11 03:33 PM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
I'm at work now (on break), so I can't test this, but it seems to me that a simple (pardon the pun) alias that calls the /filter command and returns the results from $filtered would work just fine.

Re: $alias(FILE).total [Re: westor] #230297 03/03/11 07:40 PM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
RusselB is right about the use of filter:
Code:
alias find {
  var %file = $$1
  window -h @-
  filter -fw %file @- *alias* 
  echo -a $iif($calc($filtered -2) > 1,$v1 matches,$v1 match) found in %file
  close -@-
}
Usage:
Code:
/find test.mrc


If you have the remote files included in another folder, you may need to include the path to it. The code will check the file you search for in mirc directory.

Last edited by Tomao; 03/03/11 08:01 PM.
Re: $alias(FILE).total [Re: Tomao] #230298 03/03/11 07:51 PM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
I've changed the invisible window name to "-" and the alias trigger to find and aliases to match... because with aliases the filter may count it as an alias.

Re: $alias(FILE).total [Re: Tomao] #230299 03/03/11 08:00 PM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
I've edited it again because of a couple of overlooked matters.

Re: $alias(FILE).total [Re: Tomao] #230300 03/03/11 08:19 PM
Joined: Dec 2002
Posts: 2,962
S
starbucks_mafia Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
Code:
alias messup_count {
  echo -a hello blahaliasblah
  alias -r moo
}


Your wildcard match is way too general. A regular expression like /^\s*\/*[!\.]*alias\s+(-l|[^-])/ should do (some quick testing has given correct results).

Last edited by starbucks_mafia; 03/03/11 08:27 PM.

Spelling mistakes, grammatical errors, and stupid comments are intentional.
Re: $alias(FILE).total [Re: Tomao] #230301 03/03/11 08:23 PM
Joined: Feb 2006
Posts: 181
C
Crinul Offline
Vogon poet
Offline
Vogon poet
C
Joined: Feb 2006
Posts: 181
Originally Posted By: Tomao
I've edited it again because of a couple of overlooked matters.


Originally Posted By: Test.mrc
;balias
;calias
;dalias
;alias me return me
alias you return you


Your alias will match 5 times (3, if you subtract)

Using regex is a better choice.

Edit:

Using starbucks_mafia regex:

Code:
alias find {
  var %file = $scriptdir $+ $$1
  window -h @-
  filter -gfw %file @- /^\s*\/*[!\.]*alias\s+(-l|[^-])/
  echo -sc info * There are $iif($filtered > 1,$v1 matches,$v1 match) found in %file
  close -@-
}

Last edited by Crinul; 03/03/11 08:33 PM.
Re: $alias(FILE).total [Re: Tomao] #230302 03/03/11 08:38 PM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Thanks to starbucks_mafia and Crinul. I didn't think of using regex in the first place. I agree with you two completely.

Edit - lol Crinul beat me to it.

Last edited by Tomao; 03/03/11 08:39 PM.
Re: $alias(FILE).total [Re: Crinul] #230303 03/03/11 08:42 PM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Crinul, I think the $filtered still needs to be subtracted by one because of the alias find may get filtered as a count.

I mean, if you check the aliases in the same file where the alias is installed...


Last edited by Tomao; 03/03/11 08:48 PM.
Re: $alias(FILE).total [Re: Tomao] #230304 03/03/11 08:48 PM
Joined: Feb 2006
Posts: 181
C
Crinul Offline
Vogon poet
Offline
Vogon poet
C
Joined: Feb 2006
Posts: 181
No, because that's not the real number of aliases. (I think alias find should be included).

Re: $alias(FILE).total [Re: Crinul] #230305 03/03/11 08:50 PM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Oh ok. You're correct. Thanks for the clarification.

Re: $alias(FILE).total [Re: Crinul] #230306 03/03/11 08:57 PM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Originally Posted By: Crinul
I think alias find should be included.
Yes, it's included. The regex method works like a charm. Thanks you two, once again, for the improvement upon the example provided.

Re: $alias(FILE).total [Re: Tomao] #230307 03/03/11 09:26 PM
Joined: Dec 2008
Posts: 1,511
westor Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,511
Good work the code is working correctly! but it will be good to add in mirc by default!

Re: $alias(FILE).total [Re: westor] #230309 04/03/11 12:58 AM
Joined: Apr 2010
Posts: 959
F
FroggieDaFrog Offline
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 959
Instead of using a window, you could use the -k switch with /noop
Also, what about ini files?


I haven't extensively tested it but here's my version of it:
Code:
alias Aliases {
  if (!$isfile($1-)) { return 0 }
  var %m = $iif(*.ini iswm $1-,/^n\d+=\s*\/*alias\b/i,/^\s*\/*alias\b/i)
  filter -fkg $qt($1-) noop %m
  return $filtered
}



I am SReject
My Stuff
Re: $alias(FILE).total [Re: FroggieDaFrog] #230311 04/03/11 02:30 AM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
What about the .mrc extension? An alias can be made into a remote file.

Re: $alias(FILE).total [Re: Tomao] #230312 04/03/11 02:48 AM
Joined: Apr 2010
Posts: 959
F
FroggieDaFrog Offline
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 959
If the specified file is an Ini mine uses the follow regex:
/^n\d+=\s*\/*alias\b/i

It it doesn't end with .Ini it uses:
/^\s*\/*alias\b/i


I am SReject
My Stuff
Re: $alias(FILE).total [Re: FroggieDaFrog] #230313 04/03/11 06:42 AM
Joined: Jul 2007
Posts: 1,129
T
Tomao Offline
Hoopy frood
Offline
Hoopy frood
T
Joined: Jul 2007
Posts: 1,129
Did you edit your post, Froggie? It didn't look like that the last time I saw it. :P At any rate, nice work on the regex.

Re: $alias(FILE).total [Re: Tomao] #230314 04/03/11 06:54 AM
Joined: Apr 2010
Posts: 959
F
FroggieDaFrog Offline
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 959
Nope, I didn't edit it. If I did, I would have also fixed all the grammar/spelling mistakes as well(lol). But just for the sake of doing it, here's an even shorter version:
Code:
alias Aliases {
  if (!$isfile($1-)) { return 0 }
  filter -fkg $qt($1-) noop /^ $+ $iif(*.ini iswm $1-,n\d+=) $+ \s*alias(?: |$)/i               
  return $filtered
}

Ok, now that I'm done editing things here, let me make a note. All the snippets presented here have a flaw, though not MAJOR it's still a flaw; they ALL count aliases commented out with /**/

For the sake of speed and simplicity, even though I realized the bug above, I did it this way. If you'd like a version that DOESN'T count those then hit me back and I might get around to it.

Last edited by FroggieDaFrog; 04/03/11 07:06 AM.

I am SReject
My Stuff
Re: $alias(FILE).total [Re: FroggieDaFrog] #230315 04/03/11 07:40 AM
Joined: Feb 2006
Posts: 181
C
Crinul Offline
Vogon poet
Offline
Vogon poet
C
Joined: Feb 2006
Posts: 181

Originally Posted By: starbucks_mafia

Code:
alias messup_count {
  echo -a hello blahaliasblah
  alias -r moo
}



Using your alias:
1) * No such identifier: $noop (use other alias for noop $1-??)
2) Result is 2


Code:
filter -fkg <filename> !noop /^ $+ $iif(*.ini iswm $1-,n\d+=) $+ \s*\/*[!\.]*alias\s+(-l|[^-])/i


!noop prevents mIRC from displaying the * No such identifier message (is it like ~ or a bug?)

Quote:
they ALL count aliases commented out with /**/


Right you are.

Re: $alias(FILE).total [Re: Crinul] #230317 04/03/11 09:16 AM
Joined: Apr 2010
Posts: 959
F
FroggieDaFrog Offline
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 959

Last edited by FroggieDaFrog; 04/03/11 03:13 PM.

I am SReject
My Stuff
Re: $alias(FILE).total [Re: FroggieDaFrog] #230318 04/03/11 11:24 AM
Joined: Feb 2006
Posts: 181
C
Crinul Offline
Vogon poet
Offline
Vogon poet
C
Joined: Feb 2006
Posts: 181
Originally Posted By: FroggieDaFrog
what version of mIRC are you using. Because /noop wasn't added until 6.X, and late in that version


mIRC 6.35, 7.17, 7.18

Do you have 'Identifier Warning' off?

Re: $alias(FILE).total [Re: Crinul] #230319 04/03/11 12:05 PM
Joined: Apr 2010
Posts: 959
F
FroggieDaFrog Offline
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 959
Not sure what you mean, to be honest.

Wait, you said it works if you specify "!noop" instead of "noop"? Then I do believe you have an alias that has overwritten mIRC's built in /noop Commmand. To get around this I edited my last bit of code so it calls mIRC's built-in /noop instead.

Last edited by FroggieDaFrog; 04/03/11 12:18 PM.

I am SReject
My Stuff
Re: $alias(FILE).total [Re: FroggieDaFrog] #230321 04/03/11 12:41 PM
Joined: Feb 2006
Posts: 181
C
Crinul Offline
Vogon poet
Offline
Vogon poet
C
Joined: Feb 2006
Posts: 181
Code:
Then I do believe you have an alias that has overwritten mIRC's built in /noop Commmand.

No, I don't.

Open the script editor (Alt+R), then in the Options menu, click 'Identifier Warning'.

Re: $alias(FILE).total [Re: Crinul] #230322 04/03/11 01:41 PM
Joined: Dec 2008
Posts: 1,511
westor Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,511
What exactly do the "Identifier warning" on the script editor?

Re: $alias(FILE).total [Re: Crinul] #230324 04/03/11 01:52 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
noop is a built-in command and is not an identifier. The identifier warning has nothing to do with it. Even with it enabled, you should not get a warning about noop if you didn't have $ in front of it. There should not be a $ in front of noop. You can verify this by typing the following in mIRC's edit line-

//noop echo -a test

You should not receive any kind of message or echo because noop prevents the display.


Invision Support
#Invision on irc.irchighway.net
Re: $alias(FILE).total [Re: westor] #230325 04/03/11 01:54 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Originally Posted By: westor
What exactly do the "Identifier warning" on the script editor?


It just tells you if you used an identifier that isn't valid. For example, if you type:

//echo -a This is a fake identifier: $fake

With the option enabled, you will receive an error about that being an invalid identifier. If the option is disabled, it will be evaluate to $null and you'll see:

This is a fake identifier:

(It will just not show anything for the identifier)


Invision Support
#Invision on irc.irchighway.net
Re: $alias(FILE).total [Re: Riamus2] #230326 04/03/11 01:57 PM
Joined: Dec 2008
Posts: 1,511
westor Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,511
You mean something like this?

//var %t $noop(echo -a test) | %t

* No such identifier: $noop

Re: $alias(FILE).total [Re: westor] #230328 04/03/11 01:59 PM
Joined: Dec 2008
Posts: 1,511
westor Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,511
hmm nice now i understand! is there any way to enable/disable this with an alias command?

Re: $alias(FILE).total [Re: westor] #230329 04/03/11 02:03 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Originally Posted By: westor
You mean something like this?

//var %t $noop(echo -a test) | %t

* No such identifier: $noop


Yes, that will give you an error, but you should not try to use noop as an identifier. It is a command as I stated.


Invision Support
#Invision on irc.irchighway.net
Re: $alias(FILE).total [Re: Riamus2] #230330 04/03/11 02:09 PM
Joined: Jul 2006
Posts: 3,729
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,729
General reply.

You can read jaytea's post to understand why using noop with filter is a problem, and it's not about /!noop at all
$noop() doesn't exist, so if you have the identifier warning on, mirc will report an error, this is the same for any non existing alias, he could have used "thidoesnotexist", when you don't have that warning on, any non existing identifier returns $null.

Quote:
!noop prevents mIRC from displaying the * No such identifier message (is it like ~ or a bug?)
/!command only search for the builtin command and $~ident only call the
built in identifier, so as a side effect, it won't produce the error if you have the warning on.

Jaytea's post also describe the fastest way to use filter to get $filtered filled, it's to use "~~" as an alias.

Last edited by Wims; 04/03/11 02:31 PM.

Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: $alias(FILE).total [Re: Wims] #230331 04/03/11 02:39 PM
Joined: Apr 2010
Posts: 959
F
FroggieDaFrog Offline
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 959
Thanks, I just replaced noop for ~~ in my code.

Last edited by FroggieDaFrog; 04/03/11 02:39 PM.

I am SReject
My Stuff
Re: $alias(FILE).total [Re: FroggieDaFrog] #230333 04/03/11 03:03 PM
Joined: Dec 2008
Posts: 1,511
westor Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,511
FroggieDaFrog, post the new updated code to copy, thanks!

Re: $alias(FILE).total [Re: westor] #230334 04/03/11 03:09 PM
Joined: Apr 2010
Posts: 959
F
FroggieDaFrog Offline
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 959
Ok here is my alias after editions:

Code:
alias Aliases {
  if ($isid && $0 == 1) && ($script($1-)) { 
    filter -fkg $qt($v1) ~~ /^ $+ $iif(*.ini iswm $v1,n\d+=) $+ alias [^\x20]+ [^\x20]+/i               
    return $filtered
  }
}

Last edited by FroggieDaFrog; 04/03/11 03:11 PM.

I am SReject
My Stuff
Page 1 of 2 1 2