Erase SET /P Prompt after execution

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
alleypuppy
Posts: 82
Joined: 24 Apr 2011 19:20

Erase SET /P Prompt after execution

#1 Post by alleypuppy » 02 Jan 2012 16:30

Hello,

Is it possible to erase the SET /P prompt without clearing the entire screen after the execution of the prompt?

phillid
Posts: 109
Joined: 03 Apr 2010 20:27
Location: Wellington, New Zealand
Contact:

Re: Erase SET /P Prompt after execution

#2 Post by phillid » 02 Jan 2012 16:37

I believe aGerman wrote a simple little C++ program that can put chars on the screen at position X,Y. Using this, you could echo spaces over the prompt. I'm sure he's able to whip another program up? :)

--Phillid

firebloodphoenix
Posts: 16
Joined: 16 Jul 2010 01:29

Re: Erase SET /P Prompt after execution

#3 Post by firebloodphoenix » 02 Jan 2012 16:52

is this what you need?

Code: Select all

@echo off
:1
echo 1
SET /P C=[1,2,3]?
for %%? in (1) do if /I "%C%"=="%%?" goto 1
for %%? in (2) do if /I "%C%"=="%%?" goto 2
for %%? in (3) do if /I "%C%"=="%%?" goto 3
echo Incorect Selection
goto 1


:2
echo 2
SET /P C=[1,2,3]?
for %%? in (1) do if /I "%C%"=="%%?" goto 1
for %%? in (2) do if /I "%C%"=="%%?" goto 2
for %%? in (3) do if /I "%C%"=="%%?" goto 3
echo Incorect Selection
goto 2

:3
echo 3
SET /P C=[1,2,3]?
for %%? in (1) do if /I "%C%"=="%%?" goto 1
for %%? in (2) do if /I "%C%"=="%%?" goto 2
for %%? in (3) do if /I "%C%"=="%%?" goto 3
echo Incorect Selection
goto 3

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Erase SET /P Prompt after execution

#4 Post by aGerman » 02 Jan 2012 17:03

I didn't write it by myself (even if I could).
I found an interesting link:
http://pastebin.com/Em5QLzJJ :wink:

BTW: As long as the cursor is on the same line you could use the Carriage Return character as well as the Back Space character. But it's useless in your case.

Regards
aGerman

Squashman
Expert
Posts: 4486
Joined: 23 Dec 2011 13:59

Re: Erase SET /P Prompt after execution

#5 Post by Squashman » 02 Jan 2012 17:23

aGerman wrote:BTW: As long as the cursor is on the same line you could use the Carriage Return character as well as the Back Space character.
Regards
aGerman

I do love that trick but have not found any practical purpose for it other than doing this.

Code: Select all

@echo off
setlocal EnableDelayedExpansion

for /F %%a in ('copy /Z "%~dpnx0" nul') DO set "CR=%%a"

for /l %%I in (0) do (
<nul set /p "=The time now is is !time:~0,-3!!CR!"
ping -n 1 127.0.0.1 > nul
)
Last edited by Squashman on 02 Jan 2012 17:26, edited 1 time in total.

phillid
Posts: 109
Joined: 03 Apr 2010 20:27
Location: Wellington, New Zealand
Contact:

Re: Erase SET /P Prompt after execution

#6 Post by phillid » 02 Jan 2012 17:26

I wrote my own clearchars program. You can find the exe and the source at http://batchbin.ueuo.com/clearchars.zip.

Just use it like this:

Code: Select all

clearchars [X] [Y] [number of chars]

I think this is what you are looking for.

Please post any problems you have with it, so I can fix 'em :)

--Phillid

alleypuppy
Posts: 82
Joined: 24 Apr 2011 19:20

Re: Erase SET /P Prompt after execution

#7 Post by alleypuppy » 02 Jan 2012 18:17

phillid wrote:I wrote my own clearchars program. You can find the exe and the source at http://batchbin.ueuo.com/clearchars.zip.

Just use it like this:

Code: Select all

clearchars [X] [Y] [number of chars]

I think this is what you are looking for.

Please post any problems you have with it, so I can fix 'em :)

--Phillid

Hmm... it says that I'm missing a .dll file (libgcc_s_dw2-1.dll) and cannot be run. I am on a 64-bit machine, by the way.

EDIT: I was able to download a copy of it from the Internet and I got it to work. Maybe you can include that .dll with your .zip file.

phillid
Posts: 109
Joined: 03 Apr 2010 20:27
Location: Wellington, New Zealand
Contact:

Re: Erase SET /P Prompt after execution

#8 Post by phillid » 03 Jan 2012 03:21

Ah, yes that DLL is part of the MinGW C/C++ compiler which I use to compile my programs. I will rewrite that program in C tomorrow (it's 10:12 PM where I am) so it doesn't need that DLL and upload it to my site. While this thread is open, I'll mention http://batchbin.ueuo.com/gotoxy.zip which I will rewrite in C too. There should be no need for downloading of any DLLs with these programs once fixed, thanks for that bug report :)

orange_batch
Expert
Posts: 442
Joined: 01 Aug 2010 17:13
Location: Canadian Pacific
Contact:

Re: Erase SET /P Prompt after execution

#9 Post by orange_batch » 03 Jan 2012 19:11

phillid, great! Please note it said libstdc++-6.dll was missing for me with gotoxy, as well as the other DLL for both.

nitt wrote a program here that did a similar job as gotoxy but it relied on .NET. I requested a C(++) version but he was unable...

However, nitt's version I think had one feature, where if you entered negative values for X and Y, it would reposition the cursor backward from it's current position (so, relative as well as the default absolute). It's not necessary, but just take this as a suggestion (for both tools).

I'll be using your next compiled versions. It's safe to say they are freeware?

PS: There's a problem with clearchars, the first argument sets the row (Y), the second argument does nothing and the third determines the number of characters to clear.

Code: Select all

gotopos(0, atoi(argv[1]));

Should be like it is in gotoxy?

Code: Select all

gotopos(atoi(argv[1]), atoi(argv[2]));

Also, should clearchars not set the cursor position back to where the cursor started, or at least to the beginning of the position where text was cleared? I think you might've intended it to return, here:

Code: Select all

gotopos(cursor.x, cursor.y);

But that just sets the cursor to it's current position which was already changed, so you need to store the starting position in variables, right...?

phillid
Posts: 109
Joined: 03 Apr 2010 20:27
Location: Wellington, New Zealand
Contact:

Re: Erase SET /P Prompt after execution

#10 Post by phillid » 15 Jan 2012 23:27

Orange_batch, thanks for that :)
I did forget about this thread, but now I'm back on it and I will address all of your comments now:

The case of the missing DLL
This is due to my C++ compiler. I will re-write both programs in C. My C compiler does not say that you need these DLLs.

Relative cursor positions
Great idea! I'll be adding a switch to gotoxy's command line syntax to enable relative cursor positioning.

Freeware?
More than freeware, it's open source. You are absolutely free to dish the programs out to anyone, although I would appreciate an acknowledgement (maybe just 'Thanks, http://batchbin.ueuo.com/') to be stuck your program(s) (maybe the help or about?) somewhere if you are distributing it/them. :) Great to know someone will use them :D

Bugs, bugs and more bugs
Thanks for pointing that out, I will have a look at the code tonight. I whacked the first versions of these programs together in about 2 minutes each, so I thought I'd get bug reports back. I will rewrite them in C and do some serious debugging tonight :)

I'd better get to some programming... I'll build on the website when I can. Maybe giving it a homepage would be a start :P Look on the site (when I get the homepage made) for updates and news on the programs

--Phillid

Post Reply