mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Mar 2005
Posts: 39
B
Ameglian cow
OP Offline
Ameglian cow
B
Joined: Mar 2005
Posts: 39
Hello, how can I split Something/SomethingOther into %something and %somethingother ? Like, I want to grab the thingie before / into %something and the thingie after the / into %something other..

Joined: Apr 2004
Posts: 759
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Apr 2004
Posts: 759
This is a case for tokens. A token is a string with a delimiter at the end. In normal writing these are .'s to indicate sentences, a sentence is a token because . delimits them. in your case / is the delimiter. so $gettok(something/somethingelse,1,$asc(/)) will return the first token "something".


$maybe
Joined: Apr 2004
Posts: 218
P
Fjord artisan
Offline
Fjord artisan
P
Joined: Apr 2004
Posts: 218
Also maybe a simpler way using the /tokenize <C> <Text> command:
--
tokenize 47 something/something-else
set %var $1-
--

%var will output "something something-else"
sort of like split() for PHP.
You could then return each "something" or "something-else" via the $1 or $2 identifiers.


Another example if you're lost (and more of what you asked in the first place):
--
tokenize 47 hello/there/mate
var %output1 = $1
var %output2 = $2
var %output3 = $3
--

The outputs:
%output1 - hello
%output2 - there
%output3 - mate

-Zach


Live to Dream & Dream for Life

Link Copied to Clipboard