Page 1 of 1

Erase SET /P Prompt after execution

Posted: 02 Jan 2012 16:30
by alleypuppy
Hello,

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

Re: Erase SET /P Prompt after execution

Posted: 02 Jan 2012 16:37
by phillid
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

Re: Erase SET /P Prompt after execution

Posted: 02 Jan 2012 16:52
by firebloodphoenix
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

Re: Erase SET /P Prompt after execution

Posted: 02 Jan 2012 17:03
by aGerman
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

Re: Erase SET /P Prompt after execution

Posted: 02 Jan 2012 17:23
by Squashman
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
)

Re: Erase SET /P Prompt after execution

Posted: 02 Jan 2012 17:26
by phillid
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

Re: Erase SET /P Prompt after execution

Posted: 02 Jan 2012 18:17
by alleypuppy
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.

Re: Erase SET /P Prompt after execution

Posted: 03 Jan 2012 03:21
by phillid
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 :)

Re: Erase SET /P Prompt after execution

Posted: 03 Jan 2012 19:11
by orange_batch
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...?

Re: Erase SET /P Prompt after execution

Posted: 15 Jan 2012 23:27
by phillid
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