On Sep 5, 2006, at 1:07 AM, Ronald Vogelaar wrote:

Hi all,

I need to execute a small program, using RB's Shell class. This program can read its data either from file or from stdin. I would really like to have it read from stdin, but the problem is this: when it executes without the name of a file on the command line, it just sits there, waiting for input from stdin. There's no output to catch in order to know when to execute the shell.write command, and doing this:

shell.execute "thatfile.exe"
shell.write "some text to be processed"

...obviously does not work

Is there someone who can give me a hint?

Hi Ronald,

First - make sure the Shell's Mode is 2
Second - since you seem to be on Windows, set the timeout value to -1
Third, use the much maligned App.DoEvents() to pause without bogging the interface

        Dim myShell As New Shell

        myShell.Mode = 2
        If TargetWin32 Then
                myShell.Timeout = -1 // Not required if not Windows
        End If

        myShell.Execute "thatfile.exe"
        App.DoEvents(1000)  // wait one second - may need to adjust
        myShell.WriteLine "some text to be processed"

        Do
                App.DoEvents(10)
        Loop Until Not myShell.IsRunning

        // Handle results here...

Since I created the myShell instance in code in this sample instead of by dropping a Shell class into our project, we don't have easy access to the "Completed" event. Thus the Do ... Loop Until to monitor the myShell.IsRunning flag. If you do add a Shell to your project in the IDE and then subclass it, you won't need the Do ... Loop Until as the Completed event will fire when the execution completes and you can put your finish up code inside of that event.

HTH,
Tim
--
Tim Jones                                       [EMAIL PROTECTED]

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to