How to implement check input by batch bat
Editor to share with you how to achieve batch bat check input, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to understand it!
The code is as follows:
@ echo off
Set massif 0
: agn
Set / a macaque 1
If m gtr 5 (
Echo. The five opportunities have been used up and will exit automatically in 3 seconds.
Ping-n 4 127.1 > nul
Goto: eof
)
Please enter 3 to 10 letters for set input=&set / p input=:
If not defined input (echo. Content cannot be empty!! & goto: agn)
Echo.%input% | findstr / I / v "^ [a Murz] * $" > nul&& (echo. Please enter pure English letters!! & goto: agn)
Set nasty 0
: count
Set / a naughty 1
If not "% input:~1%" = "" (set input=%input:~1%&goto: count)
If n lss 3 (
Echo. Enter no less than 3 letters! Please re-enter!
Goto: agn
) else (
If n gtr 10 (
Echo. You typed too much! Please re-enter!
Goto: agn
)
)
Set / p = what you enter is within the allowed range. Please press any key to exit. Nul
Goto: eof
The above is all the content of the article "how to check input in batch bat". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!