mIRC Home    About    Download    Register    News    Help

Print Thread
G
grizzzli
grizzzli
G
i have
$regex($strip($1-),.*mins.*)
var %minute = $regml(1)

if (%minutes < 25) never work

need to convert string to int ?

thx

Joined: Dec 2002
Posts: 787
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 787
What is the actual string your trying to "use" ?

For example, a string of;

10mins.

Using code:

$remove(10mins.,mins.)

Will return, 10.

Eamonn.

G
grizzzli
grizzzli
G
no my string result is 24
no need cast to int ?

never go into frown

if (%minute < 25) {
echo here
}

S
saragani
saragani
S
alias reg {
var %minute
if ($regex($strip($1-),(\d+)[\s+]*mins)) { %minute = $regml(1) | echo -a %minute }
}



It works for Number Mins and NumberMins

S
saragani
saragani
S
Btw, there is no need to convert anything to a int or string. mIRC knows how to handle it. in mIRC any variable is a string. If it contains only number, then using isum will return 1/$true , and if you use inc or dec, it will increase/decrease its value.

Joined: Feb 2004
Posts: 2,013
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Feb 2004
Posts: 2,013
Hi

just wanted to let you know that a quantifier loses it's meaning whithin a character class. Like in your example you put the + inside a character class, which now means: [\s+] will match a whitespace (space or tab) or a +

//echo -a $regex(15++++++ mins,/(\d+)[\s+]*mins/)
--> 1

Also thanks to the S parameter, the input string is stripped from control codes, and
i makes the match case insensitive, so it could match on MINS or Mins ...

--> $regex($1-,/..../Si)

Depending on how the user will use this script, we could also make it react to decimal numbers like 15.5 mins etc.

--> (\d+(?:\.\d+)?)

Code:
if $regex($1-,/(\d+(?:\.\d+)?)\s*mins/Si) {
var %mins = $regml(1)
...
}

Greets

Last edited by FiberOPtics; 03/08/04 03:01 PM.
Joined: Dec 2002
Posts: 1,893
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,893
It's worth mentioning that $calc has a side-effect of removing trailing letters.

//echo -a $calc(10mins.)[/color]

...returns 10 laugh

G
grizzzli
grizzzli
G
nice $calc() worked perfect

thx

Joined: Feb 2004
Posts: 2,013
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Feb 2004
Posts: 2,013
Oh I see, he already had the "xxx mins" part, heh. Thought he wanted to grab the number from a longer string like a sentence smirk

Oh well.

Joined: Dec 2002
Posts: 787
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 787
Wasnt actually aware of that seems "convient" laugh, however, since it is a "side-effect" hes going to be stuck between a rock and a hard place if Khaled alters $calc not to do this in future versions.

Eamonn.

Joined: Dec 2002
Posts: 1,893
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,893
startbucks_mafia mentioned this behavior in a recent thread in the Bugs forum, so Khaled has probably read it and will take that into consideration.

D
DaveC
DaveC
D
Try using the same variable names might help!
%minute != %minutes

Joined: Dec 2002
Posts: 787
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 787
Good catch DaveC laugh

Eamonn.


Link Copied to Clipboard