Page 1 of 1

Can't CLS during redirection - New bug or known?

Posted: 21 Jan 2023 00:10
by T3RRY
Not something I've encountered before, but found myself wanting to clear the screen between outputs during a redirected block, and CLS wouldn't work.

I did a bit of searching, couldn't find mention of the problem here previously.
I believe the issue only occurs if it's STDOUT being redirected.
Flipping the STDERR / STDOUT streams and Redirecting the STDERR handle resolves the issue

Code: Select all

@Echo off

1>"%~dp0example.tmp" (
	1>con Echo(See this?
	Echo(Can't see this, it's in the file
	CLS
	1>con Echo(Shouldn't see that but do.
)

Pause

1>&2 2>>"%~dp0example.tmp" (
	2>con Echo(You won't see this.
	CLS
	1>&2 Echo(This will go to file
	2>con Echo(You Didn't see that.
)
Title close notepad to quit
notepad "%~dp0example.tmp"

Del "%~dp0example.tmp"


Re: Can't CLS during redirection - New bug or known?

Posted: 21 Jan 2023 01:20
by Aacini
When a CLS command is redirected to a disk file, it output an ASCII 12 character, Ctrl-L called Form Feed that in most printers cause to eject current page and jump to a new page. This is a rather logical "conversion" of screen CLS command to a (paper) text file.

This conversion is well-known, but I don't remember right now where you could review it...

Antonio

Re: Can't CLS during redirection - New bug or known?

Posted: 21 Jan 2023 03:58
by T3RRY
Aacini wrote:
21 Jan 2023 01:20
When a CLS command is redirected to a disk file, it output an ASCII 12 character, Ctrl-L called Form Feed that in most printers cause to eject current page and jump to a new page. This is a rather logical "conversion" of screen CLS command to a (paper) text file.

This conversion is well-known, but I don't remember right now where you could review it...

Antonio
Thanks for the speedy reply Antonio, I had also tried redirecting the cls to con with no luck - hadn't thought to view the output in a robust text editor however. Something I'll remember for next time.

Knowing the Form Feed issue helped me find the orginal post it was discussed in. viewtopic.php?p=13680#p13680