mIRC Home    About    Download    Register    News    Help

Print Thread
#158820 10/09/06 05:12 AM
Joined: Dec 2002
Posts: 251
T
Talon Offline OP
Fjord artisan
OP Offline
Fjord artisan
T
Joined: Dec 2002
Posts: 251
I have ran into several instances, where I still need like $1 $2 etc, I have to push these into local variables before I tokenize so I dont loose these items. subtokenize would be nice to fill like $s1 $s2 $s1- all like $1 (etc), sure I guess you could local var $1-, tokenize, do your matching, then tokenize the local var again, but why? main reason I use tokenize is because it saves processing time when you need more than one instance from a particular string... like say you need token 1,3, and 6... tokenize (int) string | echo -a $1 $3 $6 works far better than individual gettoks, gettok is faster and more conveniant if you only need to pull one or a string of tokens at the same time like 1, 2, 3, or 2-3, or 3-, etc.... gettok from the same string several times deters performance because mirc has to re-split the string each time, where tokenize splits it once, and fills values...

#158821 10/09/06 05:52 AM
Joined: Dec 2002
Posts: 580
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 580
Presonally, don't like the idea.

#158822 10/09/06 07:18 AM
Joined: Sep 2005
Posts: 2,630
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,630
Not sure if this is exactly what you want, but I wrote a snippet that does something similar.

#158823 10/09/06 08:22 PM
D
DaveC
DaveC
D
nice snippet, I dont like the idea of throwing a pile of instant aliases in myself, but it does seem like it would be the best way in this case (so ill shut up about that lol)

I did notice in the on load for it a NOOP, didnt that only come in in 6.16? so if your reporting that they have a version before that while using that command?!?!??!?!

#158824 10/09/06 08:32 PM
Joined: Sep 2005
Posts: 2,630
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,630
Yeah I did that in a few of my snippets without thinking about it :tongue: I thought I'd got them all updated, but I must've missed that one. Thanks.

#158825 10/09/06 09:27 PM
Joined: Feb 2004
Posts: 201
J
Jae Offline
Fjord artisan
Offline
Fjord artisan
J
Joined: Feb 2004
Posts: 201
Quote:
Not sure if this is exactly what you want, but I wrote a snippet that does something similar.

long strings would be a little taxing surely it could be done with a similar useage efficiency using hash tables and read back as
$x(name,0) : 3
$x(name,1) : hello
$x(name,1-2) : hello world
$x(name,1-3) : hello world x
$x(name,1-) : hello world x
$x(name,2) : world
$x(name,2-3) : world x
$x(name,2-) : world x
$x(name,3) : x
$x(name,-1) : x
$x(name,-2) : world
$x(name,-3) : hello
saving overwriting alias's sure its a few chars more but doesnt creating alias's write to a file? hence performance hit?
i kind of dout we're going to get some special named tokenize command like /ntokenize <name> <char> <string>
and return it using ~name0 ~name-1 ~name1-3,5 etc
which brings me to,
/alias test123 { echo x $1-2,4 }
/test123 echo's x 1 2
sometime its a pity you cant just use ranges and seperate some by commas. althought probably easy enough to use hash tables as i said above and parse accordingly. ie -1,-3 (outputs last and 3rd last 'words')

#158826 10/09/06 09:39 PM
Joined: Sep 2005
Posts: 2,630
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,630
It more than likely does write to a file. I don't see it being particularly slow unless you end up with something like $s1-50

#158827 11/09/06 01:54 AM
D
DaveC
DaveC
D
What you want could only be created using an internal command becuase using an alias I beleive the proccessing time of calling the alias that sorts out what you want is likely to exceed the time it would take to simply do the $GETTOK.
PS: u also missed $x(name,-3-) which is just another thing u would have to code for as well, all this code being executed verse one internal command
I would bet the internal command beats it every time, your just passing a string and some 2 or 3 parameters to a internal routine.

Now i would suggest you look at $regex & $regml as i believe this may with some understanding (more than mine) well do exactly what you ask, or very close to it.

#158828 11/09/06 09:28 AM
Joined: Feb 2004
Posts: 201
J
Jae Offline
Fjord artisan
Offline
Fjord artisan
J
Joined: Feb 2004
Posts: 201
arrays could do it even more efficiently and just use something like php's explode() function and you've got pizza.. or something...

#158829 11/09/06 08:16 PM
D
DaveC
DaveC
D
Did you read this bit "Now i would suggest you look at $regex & $regml as i believe this may with some understanding (more than mine) well do exactly what you ask, or very close to it.
" ?

The $regml(name,N) is a result array(s) so you would have exactly that.

#158830 11/09/06 09:12 PM
Joined: Feb 2004
Posts: 201
J
Jae Offline
Fjord artisan
Offline
Fjord artisan
J
Joined: Feb 2004
Posts: 201
while that is true, most other uses wishing to do such a thing would still rely on knowing regex. (asuming of course many people would need such a function). that said its a good idea and worth a go if you know regex or willing to learn.


Link Copied to Clipboard