mIRC Home    About    Download    Register    News    Help

Print Thread
#51658 27/09/03 07:04 PM
Joined: Jun 2003
Posts: 114
T
Thray Offline OP
Vogon poet
OP Offline
Vogon poet
T
Joined: Jun 2003
Posts: 114
Theres something I'm trying to do, but can't seem to get it done. Basically, I have a command with the following syntax:
@Start T=RT R=Room U=Chaz, Ranma, Thray M=Multiple Word String, MPS, Etc Etc

Then I split up the info into variables. %t = RT, %r = Room, %u = Chaz.Ranma.Thray, etc. (It changes ", " to . beforehand so Multiple Word String, MPS becomes Multiple Word String.MPS and so on)

Now here is the challenge.. I want to get all the words from M= into a string of .s.. %m = Multiple Word String.MPS.Etc Etc Like that. But I want the user to be able to put m= in any place. So.. .the command could also look like:

@Start M=Multiple Word String, MPS, Etc Etc T=RT R=Room U=Chaz, Ranma, Thray

And so on. The problem above is that I keep getting the entire string in that case.

var %com = $replace($4-,$+($chr(44),$chr(32)),.,$chr(44),.)
var %t = $remove($wildtok(%com,t=*,1,32),t=)
var %r = $remove($wildtok(%com,r=*,1,32),r=)
var %u = $remove($wildtok(%com,u=*,1,32),u=)

Thats what I used to get the info.



Any help?


-------------
I am the self-appointed God of needlessly complex mIRCscript.
Joined: Aug 2003
Posts: 314
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Aug 2003
Posts: 314
You can use:

% $+ $replace($replace(command,$chr(44) $+ $chr(32),$chr(46)),$chr(32),$chr(32) $+ %))

Which will turn, for example:

1=a, b, c 2=d, e, f 3=g, h, i

Into:

%1=a.b.c %2=d.e.f %3=g.h.i

You could then loop through $numtok(that,32) and set each variable ($gettok($gettok(that,n,32),1,61)) to the value on the other side of the equals sign ($gettok($gettok(that,n,32),2,61))

Joined: Dec 2002
Posts: 77
B
Babel fish
Offline
Babel fish
B
Joined: Dec 2002
Posts: 77
You can also use...

Code:
if $regex(%com, /(?i)^@start(?=.*M=(.*?)(?:\w=|$)|())(?=.*R=(.*?)(?:\w=|$)|())(?=.*T=(.*?)(?:\w=|$)|())(?=.*U=(.*?)(?:\w=|$)|())/) {
   var %m = $regml(1)
   var %r = $regml(2)
   var %t = $regml(3)
   var %u = $regml(4)
}


That'll work no matter what order the parameters M, R, T, U are in, it will also work if any parameters are obmitted.

Joined: Feb 2003
Posts: 810
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Feb 2003
Posts: 810
This won't work with multiple word values.


* cold edits his posts 24/7
Joined: Dec 2002
Posts: 77
B
Babel fish
Offline
Babel fish
B
Joined: Dec 2002
Posts: 77
? ...works here.

Joined: Feb 2003
Posts: 810
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Feb 2003
Posts: 810
That was a reply to Sigh and his $replace() method. Yours works.


* cold edits his posts 24/7

Link Copied to Clipboard