Posts: 14
Threads: 4
Joined: May 2008
I need to setup an input box that limits the user to x amount of numbers. My current input text box specifically asks for 3 numbers, problem is users can type as may as they want at this point. Any way to limit the amount?
Posts: 12,071
Threads: 140
Joined: Dec 2002
Macro
int i
inp- i "" "" "" 0 "" inp_Limit3Digits
out i
Function
inp_Limit3Digits
;/
function# str&s
s.replacerx("\D") ;;remove nondigits
s.fix(3 2) ;;limit to 3 characters
Posts: 14
Threads: 4
Joined: May 2008
I tried both suggestions, didn't quite the way I was looking for. Following is the line asking for the input.
if(!inp(IP "please type the 3 numbers provided by the WVLC tech staff" "IP address" "")) ret
Like I mentioned, right now this opens a text box, and they can type in all the numbers they want. If I can linit it to "3", that would be awesome. 8)
Posts: 12,071
Threads: 140
Joined: Dec 2002
It is 1 suggestion. The macro shows an input box. The function runs when the user types a character in the input box. It does not allow to type more than 3 digits.
Posts: 14
Threads: 4
Joined: May 2008
I tried the Macro,
int i
inp- i "" "" "" 0 "" inp_Limit3Digits
out i
one problem is that it doesn't know what "inp_Limit3Digits" is, then I am not sure where to place it. I have already set a STR called IP. The 3 numbers I want them to type will complete the IP address as seen below ie: 10.99.IP.2. If you get a chance, can you show me where to add your Macro?
str IP
10
if(!inp(IP "please type the 3 numbers provided by the WVLC tech staff" "IP address" "")) ret
OnScreenDisplay _s.format("Starting network connection:[]IP: 10.99.%s.222 []Mask: 255.255.255.0 []GW: 10.99.%s.1[]" IP IP)15 600 600 "Arial" 14 0x00000f
Posts: 12,071
Threads: 140
Joined: Dec 2002
Macro
str IP
;g1
if(!inp(IP "please type the 3 numbers provided by the WVLC tech staff" "IP address" "")) ret
if(findrx(IP "^\d\d\d$")<0) goto g1
Posts: 14
Threads: 4
Joined: May 2008
That did it :o Thanks for your time
Posts: 60
Threads: 24
Joined: Jan 2008
Hey, I Put this together, Thought it looked a bit better.
str IP
;g1
if(!inp(IP "please type the 3 numbers provided by the WVLC tech staff" "IP address" "")) ret
if(findrx(IP "^\d\d\d$")<0) goto g2
else goto b
;g2
if(!inp(IP "You typed in more than 3numbers please try again [] Thanks WVLC tech staff" "IP address" "")) ret
if(findrx(IP "^\d\d\d$")<0) goto g2
else goto b
;b