mIRC Home    About    Download    Register    News    Help

Print Thread
#77344 31/03/04 10:53 AM
Joined: Jun 2003
Posts: 19
H
Hjorten Offline OP
Pikka bird
OP Offline
Pikka bird
H
Joined: Jun 2003
Posts: 19
How do I only allow numbers, commas and periods being written in an editbox in a dialog? Something like:
Code:
if ($did($dname,1) isnum) || ($chr(44) isin $did($dname,1)) || ($chr(46) isin $did($dname,1))  {
do_this
}
else { do_something }

Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
Here's a modified version of qwerty's /numonly:

alias xnumonly {
; /xnumonly <dialog> <id>
var %a = $did($1,$2), %s = $did($1,$2,1).selstart, %l = $mid(%a,%s,1)
if $regex(%l,[^\d.\x2C]) { did -ra $1-2 $remove(%a,%l) | did -c $1-2 1 %s }
}

(see the original link above for instructions on how to use it)

Note: numbers that contain commas are not recognized by mIRC for mathematical operations.

Joined: Jun 2003
Posts: 19
H
Hjorten Offline OP
Pikka bird
OP Offline
Pikka bird
H
Joined: Jun 2003
Posts: 19
Thanks a lot, that worked perfectly!

EDIT:
However I still have to do something when the user uses letters and other characters in the editbox... Back to the drawing board smirk.

Last edited by Hjorten; 31/03/04 03:10 PM.
Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
alias xnumonly {
...
if $regex(...) { ... | ... | your code goes here }
}

In your code you can use these identifiers: $1 = dialog name; $2 = editbox id, %a = editbox content, %l = last letter being typed.


Link Copied to Clipboard