mIRC Home    About    Download    Register    News    Help

Topic Options
#55468 - 17/10/03 04:24 PM new funciont for $mid?
ReWeNgE Offline
Bowl of petunias

Registered: 17/10/03
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

Top
#55469 - 17/10/03 04:27 PM Re: new funciont for $mid?
Collective Offline
Planetary brain

Registered: 10/12/02
Posts: 3138
Loc: London, UK
For that you might like to try the $gettok identifier.

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

Top
#55470 - 17/10/03 04:59 PM Re: new funciont for $mid?
ReWeNgE Offline
Bowl of petunias

Registered: 17/10/03
Posts: 2
thank you very much!!
work fine! smile

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

Top