You are not logged in.
Hello , I'm new here !
I'd like to ask about something if its possible to do with batching !
I Wanna let the user enter Two characters and the batch file echo them each one in line !
Lemme explain :
@echo off
Set /p AZ=">"
Let's say that the user entered EA
I want them to be printed like this
E
A
I dunno if this is possible !
Also I wanna know if i can let the user enter characters only ! Like we can let them enter numbers only !
Any tip ??
Thanks
Offline
You can use this http://stackoverflow.com/questions/1566 … a-variable if the input is only two letters
SET var=%var:~0,2%
SET var2=%var:~1,-2%
Echo %var%
Echo %var2%
This should work
Offline
There is a simple fix for testing, Batcher. You may be surprised at the result.
@echo off
set "var=EA"
SET var=%var:~0,2%
SET var2=%var:~1,-2%
Echo "%var%"
Echo "%var2%"
Offline
@echo off Set /p AZ=">"
Let's say that the user entered EA
I want them to be printed like this
E
A
Batcher gave you a clue with the syntax, but his numbers are wrong.
Also I wanna know if i can let the user enter characters only ! Like we can let them enter numbers only !
You can't make them enter numbers only, or characters only, but you can check the result after they press enter and ask them to re-enter the details again if it is wrong.
Last edited by foxidrive (28 Jun 2016 01:59)
Offline
If you're only taking two alphanumeric characters as input, couldn't you just have two choice commands?
(I'm not saying it would be easy, but it's certainly possible as long as choice exists.)
Offline
Hello , I'm new here !
It makes sense to rename your thread to something more revealing, like: "Entering 2 characters in a batch."
Offline
Thanks thanks !
im done with this ...
Offline