DosTips.com

A Forum all about DOS Batch
It is currently 02 Dec 2016 16:15

All times are UTC-06:00




Post new topic  Reply to topic  [ 10 posts ] 
Author Message
PostPosted: 02 Jan 2012 16:30 
Offline

Joined: 24 Apr 2011 19:20
Posts: 82
Hello,

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


Top
   
PostPosted: 02 Jan 2012 16:37 
Offline

Joined: 03 Apr 2010 20:27
Posts: 109
Location: Wellington, New Zealand
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


Top
   
PostPosted: 02 Jan 2012 16:52 
Offline

Joined: 16 Jul 2010 01:29
Posts: 16
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


Top
   
PostPosted: 02 Jan 2012 17:03 
Offline
Expert

Joined: 22 Jan 2010 18:01
Posts: 2408
Location: Germany
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


Top
   
PostPosted: 02 Jan 2012 17:23 
Offline
Expert

Joined: 23 Dec 2011 13:59
Posts: 3364
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.

Top
   
PostPosted: 02 Jan 2012 17:26 
Offline

Joined: 03 Apr 2010 20:27
Posts: 109
Location: Wellington, New Zealand
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


Top
   
PostPosted: 02 Jan 2012 18:17 
Offline

Joined: 24 Apr 2011 19:20
Posts: 82
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.


Top
   
PostPosted: 03 Jan 2012 03:21 
Offline

Joined: 03 Apr 2010 20:27
Posts: 109
Location: Wellington, New Zealand
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 :)


Top
   
PostPosted: 03 Jan 2012 19:11 
Offline
Expert

Joined: 01 Aug 2010 17:13
Posts: 442
Location: Canadian Pacific
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...?


Top
   
PostPosted: 15 Jan 2012 23:27 
Offline

Joined: 03 Apr 2010 20:27
Posts: 109
Location: Wellington, New Zealand
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


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 10 posts ] 

All times are UTC-06:00


Who is online

Users browsing this forum: Yahoo [Bot] and 8 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
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited