[Gambas-user] Dedicated process read subroutines in Gambas 1.0.17

Benoit Minisini gambas at ...1...
Mon May 28 11:57:24 CEST 2007


On samedi 26 mai 2007, easuter wrote:
> Hi there!
>
> I'm having some trouble making a Process_Read event read only from a
> certain process in Gambas 1.0.17.
> In Gambas2 1.9.49 for example, I would use this kind of code to read data
> from each process separately:
>
> -----Snip------
>
> PUBLIC $hProc1 AS Process
> PUBLIC $hProc2 AS Process
>
> PUBLIC SUB Command1Btn_Click()
>
>     EXEC ["command1", "flags"] FOR READ AS $hProc1
>
> END
>
> PUBLIC SUB Command2Btn_Click()
>
>    EXEC ["command2", "flags"] FOR READ AS $hProc2
>
> END
>
> PUBLIC SUB $hProc1_Read()
>
>     DIM sLine as String
>
>     PRINT "Reading output from Command1..."
>
>     LINE INPUT #$hProc1, sLine
>     PRINT sLine
>
> END
>
> PUBLIC SUB $hProc2_Read()
>
>     DIM sLine as String
>
>     PRINT "Reading output from Command2..."
>
>     LINE INPUT #$hProc2, sLine
>     PRINT sLine
>
> END
>
> ----Snip----
>
>
>
> But in Gambas 1.0.17 this doesn't work.
> The only way I can get the sub to read from the process stream is if I
> delete both the $hProc1_Read and $hProc2_Read subs and put only a
> Process_Read sub:
>
>
>
> ----Snip----
>
> PUBLIC $hProc1 AS Process
> PUBLIC $hProc2 AS Process
>
> PUBLIC SUB Command1Btn_Click()
>
>     EXEC ["command1", "flags"] FOR READ AS $hProc1
>
> END
>
> PUBLIC SUB Command2Btn_Click()
>
>    EXEC ["command2", "flags"] FOR READ AS $hProc2
>
> END
>
> PUBLIC SUB Process_Read()
>
>     DIM sLine AS String
>
>
>     PRINT "Reading output from <don't know which command!!!!>"
>
>     LINE INPUT #LAST, sLine
>
>     PRINT sLine
>
> END
> ----Snip----
>
>
>
> I need to have a sub that reads the data from only one designated process,
> not all the the process that may be executed.
>
> Do I need to make a module dedicated to each command?
> How can I do this in the simplest manner?
>
> Thanks in advance!
>
> Cheers,
>
> Eugéne

The syntax has changed between 1.0.x and 1.9.x:

In Gambas 1.9.x:

DIM hProc AS Process
DIM hProc2 AS Process

hProc = EXEC [...] FOR READ AS "MyProcess"
hProc2 = EXEC [...] FOR READ AS "MyProcess2"

PUBLIC SUB MyProcess_Read()

END

PUBLIC SUB MyProcess2_Read()

END

In Gambas 1.0.x:

DIM hProc AS Process
DIM hProc2 AS Process

EXEC [...] FOR READ AS hProc
EXEC [...] FOR READ AS hProc2

PUBLIC SUB Process_Read()

  IF LAST = hProc THEN

  ELSE IF LAST = hProc2 THEN

  ENDIF

END

Note that the 1.0.x method can be used in 1.9.x.

Regards,

-- 
Benoit Minisini




More information about the User mailing list