Last Line of a CMD window

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
hivebluet
Posts: 2
Joined: 08 Sep 2022 06:21

Last Line of a CMD window

#1 Post by hivebluet » 08 Sep 2022 06:35

I was wondering about this ever since I started to learn about batch programming. As you see in the screenshot I have provided, I have set the console window to 30 cols wide and 10 cols high, and I've echoed 10 lines and did `pause >nul` after that. But the first line seems to have disappeared? I think pause >nul OR the cursor is causing this, but is there any actual way to pause the script without making a new line? Thanks to everyone who helps. :)
Attachments
program.png
(Screenshot of my problem)
program.png (28.87 KiB) Viewed 2542 times

Aacini
Expert
Posts: 1914
Joined: 06 Dec 2011 22:15
Location: México City, México
Contact:

Re: Last Line of a CMD window

#2 Post by Aacini » 08 Sep 2022 10:07

Yes. Your problem is not caused by the pause command, but by the last echo 10 that advance the cursor to new line.

To show text with no CR+LF at end, use:

Code: Select all

set /P "=This text leaves cursor in same line" < NUL
But be aware that any leading space (or control character) in the text will be supressed...

For example, in your code:

Code: Select all

set /P "=10" < NUL
PS - In future questions do not post code (or data) in an image. Instead, enclose the code between [code] and [/code] tags (lines).

hivebluet
Posts: 2
Joined: 08 Sep 2022 06:21

Re: Last Line of a CMD window

#3 Post by hivebluet » 22 Sep 2022 12:10

Thanks for your advice!

Post Reply