[Gambas-user] Can Gambas run itself?

Benoit Minisini gambas at ...1...
Fri Dec 23 01:13:06 CET 2005


On Thursday 22 December 2005 08:55, Kchula-Rrit wrote:
> 	I'm trying to get a Gambas2 program to run another copy of itself but am
> having problems.  I'm trying to have the main program send commands into a
> file, which the second program reads with a "tail -f" command.  The main
> program receives command-responses with its own "tail -f" command.  It's
> sort of like the following:
>
>      ' Create log file.
>      Open MainLogFileName FOR CREATE AS #MainLogFile
>      . Run second program...
>      Second2Main = SHELL "gbx2 secondprog" FOR READ WRITE
>      ' Create communication file.  secondprog reads its commands from this.
>      Open Main2SecondCommFileName FOR CREATE AS #Main2SecondCommFile
>            ...
>      ' These four statements wait for secondprog to create its file.
>      IF EXIST (Second2MainCommFileName) = FALSE THEN
>           WAIT (1.0)     ' Wait for secondprog to create its comm file.
>      ENDIF
>      WAIT (1.0)
>      ' secondprog has created its file.  continue...
>      #GetResponses = SHELL "tail -f Second2MainCommFileName" FOR READ WRITE
>
>           ...
>      Process_Read()
>
>      secondprog does something similar:
>
>      ' Create log file.
>      Open SecondLogFileName FOR CREATE AS #SecondLogFile
>      ' Create communication file.  mainprog reads command-results from
> this. Open Second2MainCommFileName FOR CREATE AS #Second2MainCommFile ...
>      ' These four statements wait for mainprog to create its file.
>      IF EXIST (Main2SecondCommFileName) = FALSE THEN
>           WAIT (1.0)     ' Wait for mainprog to create its comm file.
>      ENDIF
>      WAIT (1.0)
>      ' mainprog has created its file.  continue...
>      #GetResponses = SHELL "tail -f Main2SecondCommFileName" FOR READ WRITE
>
>           ...
>      Process_Read()
>
>
>
>      I send commands from mainprog to secondprog by PRINTing to the
> Main2SecondCommFile.  secondprog sends responses by PRINTing to the
> Second2MainCommFile.
>
>      The problem is that the second program appears to receive the commands
> and do them, but nothing is sent to the file that the main program checks
> for return data.
>
>      Any Ideas?
>
> K-R
>

When you open a file, by default input/output are buffered.

Try to use the FLUSH instruction after PRINT, or adds the WRITE keyword before 
CREATE to your OPEN statements.

Regards,

-- 
Benoit Minisini





More information about the User mailing list