View unanswered posts | View active topics It is currently 20 Apr 2014 09:50



Post new topic Reply to topic  [ 10 posts ] 
Erase SET /P Prompt after execution 
Author Message

Joined: 24 Apr 2011 19:20
Posts: 82
Post Erase SET /P Prompt after execution
Hello,

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


02 Jan 2012 16:30
Profile

Joined: 03 Apr 2010 20:27
Posts: 109
Location: Wellington, New Zealand
Post Re: Erase SET /P Prompt after execution
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


02 Jan 2012 16:37
Profile WWW

Joined: 16 Jul 2010 01:29
Posts: 16
Post Re: Erase SET /P Prompt after execution
is this what you need?
Code:
@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


02 Jan 2012 16:52
Profile
Expert

Joined: 22 Jan 2010 18:01
Posts: 1683
Location: Germany
Post Re: Erase SET /P Prompt after execution
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


02 Jan 2012 17:03
Profile

Joined: 23 Dec 2011 13:59
Posts: 1530
Post Re: Erase SET /P Prompt after execution
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:
@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.



02 Jan 2012 17:23
Profile

Joined: 03 Apr 2010 20:27
Posts: 109
Location: Wellington, New Zealand
Post Re: Erase SET /P Prompt after execution
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:
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


02 Jan 2012 17:26
Profile WWW

Joined: 24 Apr 2011 19:20
Posts: 82
Post Re: Erase SET /P Prompt after execution
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:
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.


02 Jan 2012 18:17
Profile

Joined: 03 Apr 2010 20:27
Posts: 109
Location: Wellington, New Zealand
Post Re: Erase SET /P Prompt after execution
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 :)


03 Jan 2012 03:21
Profile WWW
Expert

Joined: 01 Aug 2010 17:13
Posts: 442
Location: Canadian Pacific
Post Re: Erase SET /P Prompt after execution
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:
gotopos(0, atoi(argv[1]));

Should be like it is in gotoxy?

Code:
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:
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...?


03 Jan 2012 19:11
Profile WWW

Joined: 03 Apr 2010 20:27
Posts: 109
Location: Wellington, New Zealand
Post Re: Erase SET /P Prompt after execution
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


15 Jan 2012 23:27
Profile WWW
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 


Who is online

Users browsing this forum: foxidrive, Google [Bot], npocmaka_, Yahoo [Bot] and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Forum style by Vjacheslav Trushkin for Free Forums/DivisionCore.