mIRC Home    About    Download    Register    News    Help

Print Thread
$puttok and $tokmatch #113374 03/03/05 11:27 PM
Joined: Aug 2004
Posts: 147
N
nalAAlan Offline OP
Vogon poet
OP Offline
Vogon poet
N
Joined: Aug 2004
Posts: 147
It would be nifty if $puttok would work like $replace, meaning you wouldnt have to do this
Code:
$puttok($puttok($puttok($puttok(a.s.d.f,1,1,46),2,2,46),3,3,46),4,4,46)

but just this
Code:
$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:
Code:
$puttok(1.2.3.4,$gettok($tokmatch,4,46),1,46)

or
Code:
var %i = a s d f,%i = $gettok(%i,1,32)
echo -a %i
echo -a $tokmatch

Re: $puttok and $tokmatch #113375 04/03/05 02:31 AM
Joined: Sep 2003
Posts: 4,230
D
DaveC Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Quote:
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.

Quote:
$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 ?

Quote:
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.

Re: $puttok and $tokmatch #113376 04/03/05 05:04 AM
Joined: Aug 2004
Posts: 147
N
nalAAlan Offline OP
Vogon poet
OP Offline
Vogon poet
N
Joined: Aug 2004
Posts: 147
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.

Re: $puttok and $tokmatch #113377 04/03/05 11:06 PM
Joined: Feb 2004
Posts: 2,019
FiberOPtics Offline
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Is it something like this you had in mind?

Code:
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


Gone.
Re: $puttok and $tokmatch #113378 05/03/05 02:00 AM
Joined: Aug 2004
Posts: 147
N
nalAAlan Offline OP
Vogon poet
OP Offline
Vogon poet
N
Joined: Aug 2004
Posts: 147
Well I would rather use a built in mIRC identifer.