|
Joined: Aug 2004
Posts: 142
Vogon poet
|
OP
Vogon poet
Joined: Aug 2004
Posts: 142 |
It would be nifty if $puttok would work like $replace, meaning you wouldnt have to do this $puttok($puttok($puttok($puttok(a.s.d.f,1,1,46),2,2,46),3,3,46),4,4,46) but just this $puttok(a.s.d.f,1,1,46,2,2,46,3,3,46,4,4,46) $tokmatch would work just like $ifmatch ($v1,$v2), but it would be for tokens. Example: $puttok(1.2.3.4,$gettok($tokmatch,4,46),1,46) or var %i = a s d f,%i = $gettok(%i,1,32)
echo -a %i
echo -a $tokmatch
|
|
|
|
DaveC
|
DaveC
|
It would be nifty if $puttok would work like $replace, meaning you wouldnt have to do this $puttok($puttok($puttok($puttok(a.s.d.f,1,1,46),2,2,46),3,3,46),4,4,46) but just this $puttok(a.s.d.f,1,1,46,2,2,46,3,3,46,4,4,46) While not unusable, would there be a great demand to use this? While your preposed example does actually cover something this does not you could use $puttok($deltok(a.s.d.f,2-4,46),1.2.3.4,1,46) I do like how u allowed for different token seperators on each token and its replacement, If this came about I would expect a $puttokx to take effect only on the original string (although that might be a bit harder than i first thought about) I would rather just see $puttok be able to uses ranged tokens such as $puttok(a.s.d.f,1.2.3.4,1-4,46) the string 1.2.3.4 is inserted to replace tokens 1 to 4, and just happens to be 4 tokens in this case. $tokmatch would work just like $ifmatch ($v1,$v2), but it would be for tokens. Example: $puttok(1.2.3.4,$gettok($tokmatch,4,46),1,46) I dont understand what you expect $tokmatch to hold above ? var %i = a s d f,%i = $gettok(%i,1,32) echo -a %i echo -a $tokmatch Since $gettok returns a value and you would need to store that value somewhere anyway, I dont see the point of having a $tokmatch value that returns the same thing? Where would there be a need fior this in code? ex? PS: Im not saying your idea is bad, just i cant see its use being high or needed all that much.
|
|
|
|
Joined: Aug 2004
Posts: 142
Vogon poet
|
OP
Vogon poet
Joined: Aug 2004
Posts: 142 |
I thought about $puttokx, but it won't work because $puttok deals with tokens not specific strings.
The reason for $tokmatch is so you can recall a string after a token identifer used it. Just like in the second example I gave you, the string was erased and $tokmatch recalled it. It isn't the most useful thing ever, but it comes up every once and a while.
|
|
|
|
Joined: Feb 2004
Posts: 2,013
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 2,013 |
Is it something like this you had in mind? alias mputtok {
if $0 < 4 || 3 \\ $calc($0 -4) {
echo -ac info * $!mputtok: incorrect amount of parameters
return
}
var %string = $1, %i = 2, %ii = 3, %iii = 4
while %iii <= $0 {
%string = $puttok(%string,$($ $+ %i,2),$($ $+ %ii,2),$($ $+ %iii,2))
inc %i 3 | inc %ii 3 | inc %iii 3
}
return %string
} $mputtok(a.s.d.f,1,1,46,2,2,46,3,3,46,4,4,46) returns 1.2.3.4
|
|
|
|
Joined: Aug 2004
Posts: 142
Vogon poet
|
OP
Vogon poet
Joined: Aug 2004
Posts: 142 |
Well I would rather use a built in mIRC identifer.
|
|
|
|
|