Auto Add Spaces To Entry Field?

Microsoft Windows 7 home premium
June 13, 2010 at 15:10:52
Specs: Windows 7, AMD Athlon x2/4GB
I can figure this out myself but don't have the time this week. In light of others gaining the benefit of the knowledge, I am posting this question here:

How can I get blank spaces automatically added when a BAT file user enters information at the prompt?

e.g.: User is asked to enter a telephone number. When the user enters the first number, a space is automatically added. When they enter the second set of numbers (which are 3 in the USA), another space is added and so forth. Of course the last four numbers do not get a space added afterwards.

set /p tPHONE=Enter Telephone:

This would be the prompt code.

I have a ghetto work-around that works but I wanted to see if someone could share with everyone else a more practical prose in coding. As I said, I can write this myself but don't have the time this week (and already have a functional code for it written).

How would you tackle this problem?

See More: Auto Add Spaces To Entry Field?

Report •

June 13, 2010 at 18:52:12
@ECHO OFF & setlocal enabledelayedexpansion
set pattern=1 3 3 4
for %%a in (%pattern%) do call :three %%a
set qq=%qq:~0,-1%
echo phone number entered:%qq%
goto :eof
for /L %%a in (1 1 %1) do (
choice /c:0123456789 /n>nul
set /a xx=!errorlevel!-1
set qq=!qq!!xx!
set /p =!xx!<nul
set /p = <nul
(set qq=!qq! )

Report •
Related Solutions

Ask Question