[Gambas-user] Can Gambas run itself?

Kchula-Rrit kchularrit at ...734...
Thu Dec 22 08:55:03 CET 2005


	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




More information about the User mailing list