|
Joined: Nov 2005
Posts: 42
Ameglian cow
|
OP
Ameglian cow
Joined: Nov 2005
Posts: 42 |
I have an alias which I call with an argument. This alias removes a few items from an ini file, and uses the argument to select the section from which it removes the item.
The problem comes when I call it using an identifier, usually $me. The alias evaluates $me and then attempts to remove from a section using my nick. Which isn't what I want, there is a section [$me] in the ini.
So, is there any way I can call the alias and prevent evaluation of the argument. The only thing I can think of so far is to call it in a 'flagged' way, so to make the argument -arg (ie $chr(45 $+ <arg>) however this is a bit of a pain and a tidier method would be nice.
|
|
|
|
Joined: Apr 2004
Posts: 759
Hoopy frood
|
Hoopy frood
Joined: Apr 2004
Posts: 759 |
$!me or $eval($me,0) ($($me,) is short for the latter)
$maybe
|
|
|
|
Joined: Nov 2005
Posts: 42
Ameglian cow
|
OP
Ameglian cow
Joined: Nov 2005
Posts: 42 |
Ok, I tried both the $eval($1,0) and the $($1,) flavours of that with no success, perhaps I am just being a muppet. Ok, so the script is going to be a much more powerful highlighter than mIRC's built-in one, with a lot more features and control and the ability to stop a highlight under certain conditions, such as the highlight occurring on a certain channel, or being triggered by a particular nick, or with some string in the line. All with a pretty interface of course. Its almost done, and I am currently attempting to script the ability to add ignore conditions when other ones are triggered, eg if an illegal highlight occurs on a channel then for say 60 seconds that channel and nick will be added to the ignores list. So after adding the appropirate ignores I start a timer which calls the remove alias with an argument of the highlight text to have the ignores removed from
.timer $+ %hlt_name -oic 0 $readini( %hlt_ini, %hlt_name, Delay) hlt_remig %hlt_name
and the alias looks like
alias hlt_remig {
if ( $readini( %hlt_ini, $1-, Nicks) == $readini( %hlt_ini, $1-, RemNick) ) remini %hlt_ini $1- Nicks
else writeini %hlt_ini $1- Nicks $remtok( $readini( %hlt_ini, $1-, Nicks), $readini( %hlt_ini, $1-, RemNick), 1, 44 )
if ( $readini( %hlt_ini, $1-, Channels) == $readini( %hlt_ini, $1-, RemChan) ) remini %hlt_ini $1- Channels
else writeini %hlt_ini $1- Channels $remtok( $readini( %hlt_ini, $1-, Channels), $readini( %hlt_ini, $1-, RemChan), 1, 44 )
remini %hlt_ini $1- RemNick
remini %hlt_ini $1- RemChan
timer $+ $1- off
}
basically removes the ignores (they're stored as a tokened list in an ini file) and removes the reminds of which ignores to take out. This all works like a charm, except for the highlight $me (yes you can add identifiers as highlights) where it falls over. It attempts to fiddle with the settings in the highlight for my nick. Trying the $eval and so on merely causes it to attempt to make changes to a [$1] in the inifile somewhere. Any ideas?
Last edited by Aenei; 17/12/05 02:19 PM.
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
Using the ! in the identifier (ie: $!me) is the method that I use.
|
|
|
|
Joined: Nov 2005
Posts: 42
Ameglian cow
|
OP
Ameglian cow
Joined: Nov 2005
Posts: 42 |
It just isn't working. Part of the problem is the name of the section for the alterations is passed to the alias in the argument. Now checking the active timers
* Timer $me 10s delay hlt_remig $me
its obviously being passed ok there. Trying to using $!1 in the alias just starts the code attempting to alter a section that doesn't exist. Interestingly, if you call the alias directly it works fine with $me.
|
|
|
|
Joined: Dec 2002
Posts: 2,962
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 2,962 |
If you call a timer from a script, everything within the timer's command parameter will be evaluated twice - once when the line in the script is parsed and then again when the timer is triggered and the command is called. This means if you want it to work on the actual text '$me' you need to prevent evaluation twice by using $!!me.
Spelling mistakes, grammatical errors, and stupid comments are intentional.
|
|
|
|
Joined: Nov 2005
Posts: 42
Ameglian cow
|
OP
Ameglian cow
Joined: Nov 2005
Posts: 42 |
I've made it work! Thanks very much to everyone who contributed, I certainly would not have been able to do it so neatly without you and would surely have had to resort to writing piles of variables to all sorts of odd places and it would have been an utter pig's ear. starbucks I went back to trying to call the alias not directly as I ahd before, but now at the end of the timer explicitly with a $!!me at the end rather than the variable I had used before. Long story short the following will call the alias from a timer and pass an identifer properly to it (like anyone else will ever care)
if ( $left(%hlt_name,1) == $chr(36) ) {
.timer $+ %hlt_name -oic 0 $readini( %hlt_ini, %hlt_name, Delay) .hlt_remig $chr(36) $+ $chr(33) $+ $right(%hlt_name,-1)
}
else .timer $+ %hlt_name -oic 0 $readini( %hlt_ini, %hlt_name, Delay) .hlt_remig %hlt_name
|
|
|
|
|