mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jul 2004
Posts: 9
G
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
G
Joined: Jul 2004
Posts: 9
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: 788
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 788
What is the actual string your trying to "use" ?

For example, a string of;

10mins.

Using code:

$remove(10mins.,mins.)

Will return, 10.

Eamonn.

Joined: Jul 2004
Posts: 9
G
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
G
Joined: Jul 2004
Posts: 9
no my string result is 24
no need cast to int ?

never go into frown

if (%minute < 25) {
echo here
}

Joined: Feb 2003
Posts: 282
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Feb 2003
Posts: 282
alias reg {
var %minute
if ($regex($strip($1-),(\d+)[\s+]*mins)) { %minute = $regml(1) | echo -a %minute }
}



It works for Number Mins and NumberMins

Joined: Feb 2003
Posts: 282
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Feb 2003
Posts: 282
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,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
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.

Gone.
Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
It's worth mentioning that $calc has a side-effect of removing trailing letters.

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

...returns 10 laugh

Joined: Jul 2004
Posts: 9
G
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
G
Joined: Jul 2004
Posts: 9
nice $calc() worked perfect

thx

Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
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.


Gone.
Joined: Dec 2002
Posts: 788
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 788
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,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
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.

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Try using the same variable names might help!
%minute != %minutes

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

Eamonn.


Link Copied to Clipboard