mIRC Home    About    Download    Register    News    Help

Print Thread
#59746 10/11/03 04:17 PM
Joined: Oct 2003
Posts: 30
pleur Offline OP
Ameglian cow
OP Offline
Ameglian cow
Joined: Oct 2003
Posts: 30
Ello,


I'm still working on my MSN-Mess-clone smile

I have a string (call it %blah), wich i wanna split on Retruns (CRLF)

What's the bestest (fastest) way?

Just with $gettok, or could i use TOKENIZE? or are there other methods?

Tia for ya time


------
Cheers m8!
Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
/tokenize is better than using $gettok() multiple times. If you already have valuable information in $1-, you'll have to assign it to a variable before /tokenizing the other string.

Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
Well /tokenize and $gettok() only work with a single character as the token delimiter, so you wouldn't be able to use them directly to split things at CRLF's. But more importantly if you try to set a text variable in mIRC it will ignore everything past the first CRLF. To set a variable to multi-line text you'd have to use binary variables, which means that you'd have to tokenize it yourself with a custom command.


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
I suppose a pair of /tokenizes, one on 10 and the other on 13 will split the string correctly. For example, //tokenize 10 $+(one,$crlf,two) | tokenize 13 $1- | echo $1-

You are right about variables, but there is an exception: local variables can hold text beyond CRLF.

Joined: Aug 2003
Posts: 1,831
I
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
Or you could use $remove()
//set -u30 %test $+(one,$crlf,two)
//tokenize 10 $remove(%test,$chr(13)) | echo -s $*


All variables can hold data including CRLF but the editor won't show anything past the first CRLF. The problem comes when mirc closes with such a var set. The next time it opens the vars are split at the CRLF, so you have for example:
%unrelated data
%test one
two
%othervar data

Note this doesn't happen if you use the -u switch when setting them, as these are not stored when mIRC closes and mirc overwrites the file, losing any possible previous saves (by /saveini, or opening/closing the editor).

Joined: Oct 2003
Posts: 30
pleur Offline OP
Ameglian cow
OP Offline
Ameglian cow
Joined: Oct 2003
Posts: 30
thanks for the help, but i've another problem now

"* /tokenize: line too long (line 666, script.mrc) "

i guess the tokenize command can't handle strings longer then a number of characters....

how can i solve this? Or should I just switch to the $instr-methode perhaps?

EDIT: The string has a length of *correction* 999 characters

EDIT2: When i echo the var i get:

* /echo: line too long (line 666, script.mrc)

wtf... confused

Last edited by pleur; 11/11/03 07:43 PM.

------
Cheers m8!
Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
You should be able to handle up to ~950 chars with a /command. identifiers like $gettok may be able to handle longer strings.

Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
Thanks for clarifying laugh


Link Copied to Clipboard