|
Joined: Dec 2002
Posts: 580
Fjord artisan
|
OP
Fjord artisan
Joined: Dec 2002
Posts: 580 |
alias tokenize { echo -a TEST: $1- }
alias toktest { tokenize 32 $1- } Results from typing: "/toktest This is a test"... TEST: 32 /toktest This is a test TEST: 32 This is a test You might be noticing that two lines were echoed... Is there anything useful that we can do in an aliased "/tokenize"? If not, should altering "/tokenize" even be allowable? Don't get me wrong, I'm all for keeping this if it can be used somehow. BTW, will someone refresh me on how an alias can get its own name...
; Will return "aname" - the aliases name
alias aname { return $(someidentifer) }
|
|
|
|
Joined: Jan 2003
Posts: 2,523
Hoopy frood
|
Hoopy frood
Joined: Jan 2003
Posts: 2,523 |
I can't reproduce this, I get the expected result:
TEST: 32 This is a test
As for altering /tokenize, all built-in commands can be overriden by design, I don't think Khaled should get in the business of making exceptions to whatever commands scripters see fit. If you're worried about the existence of a /tokenize alias (eg in released code) you can always use /!tokenize.
As for getting the currently executing alias name, there is no way and I don't see why anybody would need that. Getting the calling alias, now that could be of some use, but getting the alias itself? You already know which alias you're writing :tongue:
/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
I can't reproduce it, either.
Invision Support #Invision on irc.irchighway.net
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
10 to 1 he has an ON INPUT event that is tokenizing the line at some point in its code so hes just recieving the echo from that command.
|
|
|
|
Joined: Dec 2002
Posts: 580
Fjord artisan
|
OP
Fjord artisan
Joined: Dec 2002
Posts: 580 |
(DaveC) 10 to 1 he has an ON INPUT event that is tokenizing the line at some point in its code so hes just recieving the echo from that command. Dave is correct, that was the problem. ; Add this line
on *:input:*:{ tokenize 32 $1- } You can't re-alias "if"... I still believe /tokenize and for that matter /set, shouldn't be allowed to be re-aliased. There is no need to change these and it just introduces potential for abuse. At the very least it would be nice to have an option in "mIRC Options -> Other -> Lock -> Disable" that can be checked. BTW, Don't try this with /set (if you are running alot of scripts), you will seriously screw up your settings. (qwerty) As for getting the currently executing alias name, there is no way and I don't see why anybody would need that. Getting the calling alias, now that could be of some use, but getting the alias itself? You already know which alias you're writing :tongue: I like to paste this debug handling line at the end of events and aliases (only using $& here to shorten line, it's normally all on one line)... goto end | :error | .signal -n DEBUG $&
$+($script, $chr(160), $scriptline, $chr(160), $error, $chr(160), $1-) | :end
I would like to have the alias name sent to the debug signal (can get $event, but not $alias). Now if I go to paste this debug handler in to my 10,000 aliases, I really don't want to manually enter an alias name in to each one, or manually edit each one if I want to change this code. Which is why I don't have the alias name in the code. Furthermore, if you do need to make a change, this line of text is the same in every alias, so "search and replace" can be used to change all of them at once!
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
Querty mentioned the more usefull ability to get the alias that called the current one, and this would resolve your issue also, rather than having hundreds of lines u need to update as you said in a search and replace, each line simply calls the one alias $DEBUG.ALIAS($script,$scriptline,$error,$1-) and that displays the $callingalias (made up) identifier allowing all needed info to be shown.
|
|
|
|
Joined: Dec 2002
Posts: 580
Fjord artisan
|
OP
Fjord artisan
Joined: Dec 2002
Posts: 580 |
Querty mentioned the more usefull ability to get the alias that called the current one... Huh? You mean, as a feature suggestion in another thread? He didn't say anything about being able to get the calling alises in this thread... Yes, this would be nice too.
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
im reading in flat mode, its up near the top of the page.
|
|
|
|
Joined: Dec 2002
Posts: 580
Fjord artisan
|
OP
Fjord artisan
Joined: Dec 2002
Posts: 580 |
My whole point is there are "reserved words" in any programming language. There is nothing "wrong" with "reserving" /tokenize and /set from alterations.
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
Yes there is, /SET for example you might want to add special features to, such as value change tracking for debugging purposes, or simple value change critical info backup or even more advanced flags for vars such as maybe /set -aN,[$identifier|%var|N2] %variable which ever N seconds well adjust the value of %variable by the returned value of $identifier or %var or N2
There could be any number of reasons someone might want to intercept /tokenize (although i cant think of any personally)
|
|
|
|
Joined: Oct 2005
Posts: 1,741
Hoopy frood
|
Hoopy frood
Joined: Oct 2005
Posts: 1,741 |
Maybe I'm missing the point, but I can't figure why you would need to 'reserve' those particular commands as opposed to any others. mIRC already has the ability to ignore aliased commands by using the !prefix. If you are worried about someone's command alias breaking your code, you can simply prefix the relevent commands with !command. Maybe a command that disables all aliases in a script. Example:
alias set echo -a SET is not allowed
alias mytest {
set -s %var value
;Echos "SET is not allowed"
aliases off
;Disables aliased commands
set -s %var value
;Echos "Set %var to value"
aliases on
;Enables aliased commands
}
And maybe switches with the /aliases command: /aliases -aiglpuN on/off -a = all aliases -i = invert settings -g = aliases not in current script -l = aliases in current script -p = previous settings -uN = undo changes in N seconds And an identifier too: $aliases returns delimited (space, comma, etc) string that contains the state of global/local aliases. The aliases should probably revert to their previous state after the script finishes running. -genius_at_work
|
|
|
|
Joined: Dec 2002
Posts: 580
Fjord artisan
|
OP
Fjord artisan
Joined: Dec 2002
Posts: 580 |
Leaving /set out of the picture for now... An aliased /tokenize screws with this commands ability in a non-productive way, look at this...
alias tokenize {
tokenize $1-
; Probably does nothing, but...
return $result
}
alias test {
tokenize 32 $2-
echo -s TEST: $1-
}
Command: "/test 1 2 3" Expected Output: "TEST: 2 3" Actual Output: "TEST: 1 2 3" I actually would like to be able to mess with /tokenize right now, then I could script this. The problem here is, unlike /set (which passes %Var without evaluating it), $2- IS being evaluated before passing the argument. An aliased tokenize would need to see the text "32" in it's $1 and the text "$2-" in it's $2 (rather than what $2- has evaluated to), so that it can pass to mIRC's internal /tokenize properly. I can't see any way to alias tokenize without breaking it's ability to tokenize.
Last edited by NaquadaServ; 15/11/06 09:28 PM.
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
Actually thats not the problem at all i think, The 32 and the $2- is passed as needed to he alias and that tokenizies it correctly out of the $1-, the problem arrises that this only occurs in the alias that was called, so it does not effect the $1- in the calling alias, Thus apon return to the calling alias the original $1- is still intacked, as with any alias called not effoecting the callers $1-.
This I do see as a significant problem and with that in mind, i would agree that tokenize maybe should be made a special case, and not be aliasable, or at least from now on im going to use /!tokenize in my scripts.
Just back on the /SET alias Its interesting to note that if you create a /SET alias and then say did /SET %var 1 that the $1 = "%var" and $2 = "1" the %var does not get evaluated, just as it would not in the case of the original /SET cmd, this appears to hold for anything command with speical properties like /set.
|
|
|
|
Joined: Oct 2003
Posts: 313
Fjord artisan
|
Fjord artisan
Joined: Oct 2003
Posts: 313 |
To affect the current alias's parameters, you would have to do something like !tokenize 32 $tokenize($instok($2-,32,1,32)) - which kind of defeats the object.!
Sais
|
|
|
|
Joined: Sep 2003
Posts: 4,230
Hoopy frood
|
Hoopy frood
Joined: Sep 2003
Posts: 4,230 |
If i was the designer I would personally make tokenize a special case command, that if its overridden, then what ever $1- is as it exits, becomes the $1- of the calling alias.
How easy/hard this might be i have no idea.
|
|
|
|
|