mIRC Home    About    Download    Register    News    Help

Print Thread
new funciont for $mid? #55468 17/10/03 03:24 PM
Joined: Oct 2003
Posts: 2
R
ReWeNgE Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
R
Joined: Oct 2003
Posts: 2
Hi all.
I would have a new function (if not exist already) for the command $mid ... and i suggest to use $midn grin

So... the function that i suggest is:

$midn(text,S,F)
Returns characters between position S and F in text.

This because... i have a string as: xxxx yyyy zzzz
If i want the part of this string after the first space but before of the second... therefore "yyyy" .... but i don't know how many characters are before and after "yyyy" i must to use $mid and $pos...

In fact the function $mid need S (position to star in text) and N (the number of character)... but i only know that there are 2 space in this string and between which there is mine "yyyy"... therefore i use this command:

set %text xxxx yyyy zzzz
set %pos1 $pos(%text,$chr(32),1) return 5
set %pos2 $pos(%text,$chr(32),2) return 10
set %char $calc(%pos2 -%pos1 -1) return 4 (lengh of yyyy)
set %find $mid(%text,%pos1,%char) return yyyy

It's too long!?!?!?!?! crazy
It's possible to implement this new function? $midn grin

Bye bye!!

P.S. If someone have another idea to resolve my problem i'll be happy for discussing of this wink

Re: new funciont for $mid? #55469 17/10/03 03:27 PM
Joined: Dec 2002
Posts: 3,138
C
Collective Offline
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,138
For that you might like to try the $gettok identifier.

//echo -a $gettok(xxxx yyyy zzzz,2,32)

Re: new funciont for $mid? #55470 17/10/03 03:59 PM
Joined: Oct 2003
Posts: 2
R
ReWeNgE Offline OP
Bowl of petunias
OP Offline
Bowl of petunias
R
Joined: Oct 2003
Posts: 2
thank you very much!!
work fine! smile

i think i'm too tired...
stop scripting today
Cya