On Tue, 20 Sep 2016, Phil Underhill wrote:
> Hi all,
> I'm working on a project that would benefit from being able to receive
> events from an array of Process controls. I've been successful in
> creating the array, but the Process.Read and Process.Error events
> don't seem to be triggered once the controls are in the array.
> For example...
> Public myConns As New Process[]
> Public Sub something()
>   Dim connShell as Process
>   Shell "/usr/bin/blah" For Read As "connShell"
>   myConns.Add(connShell)
> End

connShell is Null when you add it to the myConns array. Just because you
call Shell and have a local Process variable, it doesn't magically get
filled with the process created by Shell. You have to assign Shell's return
value to the variable:

  Dim connShell As Process

  connShell = Shell "/usr/bin/blah" For Read As "connShell"

I'm not sure if it shouldn't work anyway (even if your array does not hold
any Process object) as I suppose a Process object which is opened For Read
would be referenced by interpreter automatically and therefore not be
destroyed as soon as you leave the local scope (which I believe to be the
reason you receive no events).

But first you should just try what I suggested above and actually keep
references to your Process objects.


"There's an old saying: Don't change anything... ever!" -- Mr. Monk

Gambas-user mailing list

Reply via email to