mIRC Home    About    Download    Register    News    Help

Print Thread
#252177 26/03/15 03:40 PM
Joined: Jan 2015
Posts: 12
T
Pikka bird
OP Offline
Pikka bird
T
Joined: Jan 2015
Posts: 12
Hi, this is more of a question than an actual script. It is possible to have a parameter with a space, or multiple, in it?

E.g. !testing "Buy apple" 5

Thanks!

Joined: Dec 2008
Posts: 1,515
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,515
Of course you can..

Help details: /help on text


Need Online mIRC help or an mIRC Scripting Freelancer? -> https://irc.chathub.org <-
Joined: Jan 2015
Posts: 12
T
Pikka bird
OP Offline
Pikka bird
T
Joined: Jan 2015
Posts: 12
I might have said my question wrong.. or not.

E.g. !testing "Buy apple" 5

Param 1 : !testing
Param 2 : Buy apple
Param 3 : 5

Is it more clear? I think it can be done by regex though

Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
Tokens are delimited by a single character, space by default. You'll need a more precise parsing scheme; regex is one possibility.

Joined: Dec 2008
Posts: 1,515
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,515
Code:
ON *:TEXT:!testing *:#: {
echo -a ONE: $1
echo -a TWO: $2
echo -a THREE: $3
}


Need Online mIRC help or an mIRC Scripting Freelancer? -> https://irc.chathub.org <-
Joined: Jan 2015
Posts: 12
T
Pikka bird
OP Offline
Pikka bird
T
Joined: Jan 2015
Posts: 12
As I said, it's not what I want. Your code output this:

ONE: !testing
TWO: "Buy
THREE: apple"

and I want :

ONE: !testing
TWO : "Buy apple"
THREE: 5

But yeah I'll do it with a regex I just wanted to know if there was another method rather than use a regex

Joined: Dec 2008
Posts: 1,515
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,515
There is an other way but if you know regex it will be more easy if you dont so reply to give u the other way, also i am not an magician for what you want just when you posting something add an short description on it to make us understand better..


Need Online mIRC help or an mIRC Scripting Freelancer? -> https://irc.chathub.org <-
Joined: Feb 2003
Posts: 3,432
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
This is one way to do it. Try change it to get it as you want it to be.
Code:
on *:text:!testing *:#: {
  var %x = 1
  ; change $2- to $1- will include !testing to the echo
  while ($gettok($2-,%x,32)) {
    echo -a %x : $gettok($2-,%x,32)
    inc %x
  }
}


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Joined: Dec 2008
Posts: 1,515
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,515
Originally Posted By: sparta
This is one way to do it. Try change it to get it as you want it to be.
Code:
on *:text:!testing *:#: {
  var %x = 1
  ; change $2- to $1- will include !testing to the echo
  while ($gettok($2-,%x,32)) {
    echo -a %x : $gettok($2-,%x,32)
    inc %x
  }
}


He want something else (with loop again not $chr(32) but $chr(34) character)


Need Online mIRC help or an mIRC Scripting Freelancer? -> https://irc.chathub.org <-
Joined: Feb 2003
Posts: 3,432
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Feb 2003
Posts: 3,432
Ahh. ok. smile


if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
Solution:

tokenize 32 !testing "Buy apple" 5
var %pcnt = $regex($1-,/(?:"(.*?)"|(\S+))/g)
echo -a $regml(1) = !testing
echo -a $regml(2) = Buy apple
echo -a $regml(3) = 5


%pcnt will give you the total parameter count to loop through $regml().


Well. At least I won lunch.
Good philosophy, see good in bad, I like!

Link Copied to Clipboard