Sign in to follow this  
Followers 0
HockeyFan

StdoutRead() Question

4 posts in this topic

#1 ·  Posted (edited)

Hi!

I was wondering if someone could explain to me what the first blank msgbox is that I get when i run the following example script from the help file:

; Demonstrates StdoutRead()

#include <Constants.au3>

Local $foo = Run(@ComSpec & " /c dir foo.bar", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)

Local $line

While 1

$line = StdoutRead($foo)

If @error Then ExitLoop

MsgBox(0, "STDOUT read:", $line)

Wend

While 1

$line = StderrRead($foo)

If @error Then ExitLoop

MsgBox(0, "STDERR read:", $line)

Wend

MsgBox(0, "Debug", "Exiting...")

Is there a way to prevent this first "Blank" msgbox from being displayed?

Thanks!

Edited by HockeyFan

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi!

I was wondering if someone could explain to me what the first blank msgbox is that I get when i run the following example script from the help file:

; Demonstrates StdoutRead()

#include <Constants.au3>

Local $foo = Run(@ComSpec & " /c dir foo.bar", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)

Local $line

While 1

$line = StdoutRead($foo)

If @error Then ExitLoop

MsgBox(0, "STDOUT read:", $line)

Wend

While 1

$line = StderrRead($foo)

If @error Then ExitLoop

MsgBox(0, "STDERR read:", $line)

Wend

MsgBox(0, "Debug", "Exiting...")

Is there a way to prevent this first "Blank" msgbox from being displayed?

Thanks!

Just don't show it if it's empty:
If StringStripWS($line, 8) <> "" Then MsgBox(0, "STDOUT   read:", $line)

Edit: Actually, I like the answer from Hubertus72 better...

:P

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

try this:

#include <Constants.au3>
Local $line = "", $foo = Run(@ComSpec & " /c dir foo.bar", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
While Not @error
    $line &= StdoutRead($foo)
WEnd
MsgBox(0, "STDOUT read:", $line)

$line = ""
While Not @error
    $line &= StderrRead($foo)
WEnd
MsgBox(0, "STDERR read:", $line)

MsgBox(0, "Debug", "Exiting...")
Thanks Hubertus72. :)

Not sure I completely comprehend the concept :( , still working it through :idea: , but it does what I need. Thanks again!! :P

Share this post


Link to post
Share on other sites

When I ran this I got the directory listing for a directory of choice. I did not have foo.bar on my machine naturally. When I ran it with redirection or with a non command interpreter .exe I got NO output. I am not sure why

Hi!

I was wondering if someone could explain to me what the first blank msgbox is that I get when i run the following example script from the help file:

; Demonstrates StdoutRead()

#include <Constants.au3>

Local $foo = Run(@ComSpec & " /c dir foo.bar", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)

Local $line

While 1

$line = StdoutRead($foo)

If @error Then ExitLoop

MsgBox(0, "STDOUT read:", $line)

Wend

While 1

$line = StderrRead($foo)

If @error Then ExitLoop

MsgBox(0, "STDERR read:", $line)

Wend

MsgBox(0, "Debug", "Exiting...")

Is there a way to prevent this first "Blank" msgbox from being displayed?

Thanks!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0