$split.text()
mIRC Code
+ 0 likes
Please Register to submit score.
| Average Score | 7.0 |
| Scores Submitted | 1 |
| Date Added | Dec 21, 2007 |
| Last Updated | Dec 22, 2007 |
| Tags | split text |
|
|
Introduction
It simply splits your text up.
$split.text(hiiiii,32) would echo "h i"
The format is $split.text(string,C,N)
Examples:
//noop $split.text(test,32,100)
//noop $split.text(test,44,1)
The last number ($3) will specify where to split the lines.
//noop $split.text(hello whats up,44,10) would echo the following:
h,e,l,o,w,a
t,s,u,p
The "N" parameter is optional.
I don't know if there's any easier way of doing it, but this works just fine :)
01. Now supports the propery ".dup" which will show the duplicates.
02. Fixed a error (max split number 400)
03. It now returns the reults if there was no split in the text, so
it can be used as an identifier, if it splits it will echo the
information instead.
Enjoy!
mIRC Snippet:
$split.text()
Posted on Dec 22, 2007 8:24 am
Posted on Dec 22, 2007 8:24 am
No comments? Blargh.
mIRC Snippet:
$split.text()
Posted on Dec 22, 2007 11:41 am
Posted on Dec 22, 2007 11:41 am
It's a good idea but imho, there are some things that it does which should not.
1) removal of double chars (most probably because of the $addtok's natural behaviour)
2) even though the chars in double are not close to each other, one of them, the second one, is removed also (once more, $addtok's fault).
3) //echo $split.text(mirc,44,5) echoes
m,i,r
c
which imo in not what it should do because the text in input does not even contain 5 chars. When spliting at N, it should not count the Cs also.
Furthermore, the error message will never be displayed, for the simple reason that you set %k inside a condition that is out of context when an error, in this case, is to be detected.
What I would like it to do.
1) with $split.text(text,44) it should echo "t,e,x,t" and not "t,e,x"
2) with $split.text(text,44,5) it should echo "t,e,x,t" also and not "t,e,x"
"t"
for the same reason I gave above.
Alright for the 'review'.
[ $mid is your friend :p ]
[ I'll try to scratch something like this with regexps (my passion lol) ]
Cordialement
1) removal of double chars (most probably because of the $addtok's natural behaviour)
2) even though the chars in double are not close to each other, one of them, the second one, is removed also (once more, $addtok's fault).
3) //echo $split.text(mirc,44,5) echoes
m,i,r
c
which imo in not what it should do because the text in input does not even contain 5 chars. When spliting at N, it should not count the Cs also.
Furthermore, the error message will never be displayed, for the simple reason that you set %k inside a condition that is out of context when an error, in this case, is to be detected.
What I would like it to do.
1) with $split.text(text,44) it should echo "t,e,x,t" and not "t,e,x"
2) with $split.text(text,44,5) it should echo "t,e,x,t" also and not "t,e,x"
"t"
for the same reason I gave above.
Alright for the 'review'.
[ $mid is your friend :p ]
[ I'll try to scratch something like this with regexps (my passion lol) ]
Cordialement
mIRC Snippet:
$split.text()
Posted on Dec 22, 2007 12:03 pm
Posted on Dec 22, 2007 12:03 pm
There you go.
Usage: $_split(<string>,[C])
I didn't included N because it's only "Another way to do it". :)
Usage: $_split(<string>,[C])
| Code: |
| alias _split { var %label = $color(info) * $!_split(<string>,[C]): if $isid { if $1 { var %sep = $chr($iif($2,$v1,32)) return $left($regsubex($1,/(.)/g,\\1%sep),-1) } else { echo %label insufficient parameters } } else { echo %label use only as an identifier! } } |
I didn't included N because it's only "Another way to do it". :)
mIRC Snippet:
$split.text()
Posted on Dec 22, 2007 12:10 pm
Posted on Dec 22, 2007 12:10 pm
I fixed the "error" where it split the lines incorrectly.
The not including doubble chars was something I wanted, so thats why :P.
(And I know about that $regsubex thingy :P)
But mine is faster:
Regsubex (Yours): 1735
Regular (Mine): 937
Tested with:
(Change the alias to $split.text to see mine)
So there you go :P
The not including doubble chars was something I wanted, so thats why :P.
(And I know about that $regsubex thingy :P)
But mine is faster:
Regsubex (Yours): 1735
Regular (Mine): 937
Tested with:
| Code: |
//var %x = 10000, %y = $ticks | while (%x) { noop $_split(hi) | dec %x } | echo -a Regsubex: $calc($ticks - %y) |
(Change the alias to $split.text to see mine)
So there you go :P
mIRC Snippet:
$split.text()
Posted on Dec 22, 2007 12:18 pm
Posted on Dec 22, 2007 12:18 pm
My coding was not in any way done to compete with yours. It's just that I've some kinda 'Perlish' philosophy which is "There is more than one way to do it". As for the speed concerns, ok, i'm beated. But that's not important really (for me personnally ;)) when it's only that amount of milliseconds on 10000 passes. And if the issues I've pointed out were wanted, then ok. :o)
Cordialement
Cordialement
mIRC Snippet:
$split.text()
Posted on Dec 22, 2007 12:21 pm
Posted on Dec 22, 2007 12:21 pm
Well, in this matter regex doesn't really change much. It's basically the same thing, and if you want to split, you'd still have to loop which would make it even slower.
So your code will most likely be ~5 lines shorter, but slower.
Yes, its an alternative, but not the best one :P
So your code will most likely be ~5 lines shorter, but slower.
Yes, its an alternative, but not the best one :P
mIRC Snippet:
$split.text()
Posted on Dec 22, 2007 5:26 pm
Posted on Dec 22, 2007 5:26 pm
TropNul: Made the duplicate thingy optional, see author notes.
mIRC Snippet:
$split.text()
Posted on Dec 22, 2007 6:40 pm
Posted on Dec 22, 2007 6:40 pm
I'd like to know what purpose your friend had for this. Just curious to know really.
Anyway, as stated above by TropNul, you will receive no error message in your else event because there would be no %k.
Otherwise it seems to be thorough and coded well. Gj.
Anyway, as stated above by TropNul, you will receive no error message in your else event because there would be no %k.
Otherwise it seems to be thorough and coded well. Gj.
mIRC Snippet:
$split.text()
Posted on Dec 22, 2007 6:45 pm
Posted on Dec 22, 2007 6:45 pm
Else event will trigger if "if ($isid) && ($2) {" is false...
My friend needed this to split text basically?
My friend needed this to split text basically?
mIRC Snippet:
$split.text()
Posted on Dec 22, 2007 6:48 pm
Posted on Dec 22, 2007 6:48 pm
Not exactly. You would receive an error message when using /echo because there would be no message to echo. Just move %k down into your else event.
mIRC Snippet:
$split.text()
Posted on Dec 22, 2007 7:02 pm
Posted on Dec 22, 2007 7:02 pm
You're most likely talking about
Atleast thats what im talking about.
And use //noop for exampple.
| Code: |
else { $iif($isid,return,echo -ae) %k } |
Atleast thats what im talking about.
And use //noop for exampple.
mIRC Snippet:
$split.text()
Posted on Dec 22, 2007 7:10 pm
Posted on Dec 22, 2007 7:10 pm
| Code: |
| else { $iif($isid,return,echo -ae) %k } |
Replace with:
| Code: |
| var %k = * $!split.text(): else { $iif($isid,return,echo -ae) %k } |
And remove %k from var %x = $remove($1,$chr(32)), %t = $2, %y = $len(%x), %i = 1, %z = 1, %h, %j = $iif($3,$3,50), %k = * $!split.text():
Whilst you won't receive error messages in echo -ae %k $error and $iif($isid,return,echo -ae) %k
mIRC Snippet:
$split.text()
Posted on Dec 22, 2007 7:13 pm
Posted on Dec 22, 2007 7:13 pm
Oh thats right. I didnt look at it that way. Thanks.
mIRC Snippet:
$split.text()
Posted on Dec 22, 2007 7:20 pm
Posted on Dec 22, 2007 7:20 pm
Hehe, no problem. I can be a bit vague in my comments anyway.
mIRC Snippet:
$split.text()
Posted on Dec 22, 2007 8:29 pm
Posted on Dec 22, 2007 8:29 pm
Fixed a few "bugs", see author notes.
(This was meant to be something quick, yet it ended up so "big" hehe)
(This was meant to be something quick, yet it ended up so "big" hehe)
mIRC Snippet:
$split.text()
Posted on Dec 23, 2007 6:33 am
Posted on Dec 23, 2007 6:33 am
Thanks for the update. :)







