Re: How to "Clear the Screen" for Windows Command Processor? (Windows 10)

2019-05-21 Thread BoQsc via Digitalmars-d-learn

On Tuesday, 21 May 2019 at 12:51:41 UTC, Adam D. Ruppe wrote:

On Tuesday, 21 May 2019 at 07:16:29 UTC, Boqsc wrote:
I'm getting unsure why executeShell works on the pause 
command, but cls that is responsible for clearing the text do 
not.


When you ran pause, did it print the text "press any key to 
continue"?



You are absolutely correct.
There was no output, it was captured, as executeShell is used for 
capturing command output.


auto commandOutput = executeShell("pause");
writeln("Here is the output: ", commandOutput);
// Here is the output:  Tuple!(int, "status", string, 
"output")(0, "Press any key to continue . . . \r\n")


executeShell captures the output of the program, so I'm 
guessing no. And that is why cls does nothing - its output is 
captured into a string instead of displayed on screen.


spawnShell keeps the output connected unless you ask it not to.
http://dpldocs.info/experimental-docs/std.process.spawnShell.1.html


Thanks for summarising.


Re: How to "Clear the Screen" for Windows Command Processor? (Windows 10)

2019-05-21 Thread Adam D. Ruppe via Digitalmars-d-learn

On Tuesday, 21 May 2019 at 07:16:29 UTC, Boqsc wrote:
I'm getting unsure why executeShell works on the pause command, 
but cls that is responsible for clearing the text do not.


When you ran pause, did it print the text "press any key to 
continue"?


executeShell captures the output of the program, so I'm guessing 
no. And that is why cls does nothing - its output is captured 
into a string instead of displayed on screen.


spawnShell keeps the output connected unless you ask it not to.
http://dpldocs.info/experimental-docs/std.process.spawnShell.1.html



Re: How to "Clear the Screen" for Windows Command Processor? (Windows 10)

2019-05-21 Thread BoQsc via Digitalmars-d-learn

On Tuesday, 21 May 2019 at 10:03:38 UTC, KnightMare wrote:

try next:
spawnShell( "cls" ).wait;


Wow, spawnShell indeed does the job as I would expect, as of 
right now. Thanks.


spawnShell Function indeed sounds like it would spawn a new shell 
instead of what it does, at first I didn't look into it very 
seriously while checking documentation.

https://dlang.org/library/std/process/spawn_shell.html


Re: How to "Clear the Screen" for Windows Command Processor? (Windows 10)

2019-05-21 Thread KnightMare via Digitalmars-d-learn

try next:
spawnShell( "cls" ).wait;




Re: How to "Clear the Screen" for Windows Command Processor? (Windows 10)

2019-05-21 Thread Jim via Digitalmars-d-learn

On Tuesday, 21 May 2019 at 07:16:29 UTC, Boqsc wrote:
I'm getting unsure why executeShell works on the pause command, 
but cls that is responsible for clearing the text do not.


import std.stdio, std.process;
void main()
{
writeln("Some text that will appear in cmd");
executeShell("cls"); // Does not clear the text?
	executeShell("pause"); // Pauses the cmd.exe to keep from 
closing itself.

}


As far as I understand [1], executeShell starts a new shell and 
executes %command% in that shell. So cls wouldn't be called in 
the shell where you wrote Some text...


[1] https://dlang.org/phobos/std_process.html#.executeShell


How to "Clear the Screen" for Windows Command Processor? (Windows 10)

2019-05-21 Thread Boqsc via Digitalmars-d-learn
I'm getting unsure why executeShell works on the pause command, 
but cls that is responsible for clearing the text do not.


import std.stdio, std.process;
void main()
{
writeln("Some text that will appear in cmd");
executeShell("cls"); // Does not clear the text?
	executeShell("pause"); // Pauses the cmd.exe to keep from 
closing itself.

}