Page 1 of 1

Restart Compiler

Posted: Sat Nov 22, 2008 2:50 pm
by Progi1984
Hello all, I use PB 4.20 & 4.30.

Actually, I look for a solution for restarting a compiler by code under Windows & Linux. Have you got some code ?

Thanks for advance...
Bye

Posted: Sat Nov 22, 2008 3:01 pm
by Mistrel
There was something for this in 4.0 or 4.10 but it was removed when the compiler switched from messages to piped input/output.

Posted: Sat Nov 22, 2008 5:05 pm
by Fred
I don't understand, what do you mean by restarting the compiler ? If it's the same IDE functionnality, we ends it (with a QUIT message) and we really reload the executable.

Posted: Sat Nov 22, 2008 5:17 pm
by Progi1984
By restarting the compiler, I wish that the compiler detects again all new userlibs created or userlibs created back.

Par redémarrer le compilateur, je souhaite que le compilateur détecte toutes les nouvelles userlibs créés ou celles recréés/modifiés.

What you said means that ?

Code: Select all

I connect to pbcompiler with -sb argument. I send an END command. I reconnect to pbcompiler with -sb argument.
Have you any small code for explaining your "dires"?

Posted: Sat Nov 22, 2008 5:22 pm
by Fred
Yes, that's it.

Posted: Sat Nov 22, 2008 5:43 pm
by Progi1984
Is this code correct ? For Windows & Linux ?

Code: Select all

Global hCompiler.l
ProcedureDLL PB_Connect()
  Protected ReponseComp.s
  ; hCompiler = RunProgram(#PB_Compiler_Home+"compilers\pbcompiler.exe", "/STANDBY", "", #PB_Program_Open|#PB_Program_Read|#PB_Program_Write|#PB_Program_Hide)
  hCompiler = RunProgram(#PB_Compiler_Home+"compilers/pbcompiler", "-sb", "", #PB_Program_Open|#PB_Program_Read|#PB_Program_Write|#PB_Program_Hide)
  If hCompiler = 0
    ProcedureReturn #False
  Else
    While ProgramRunning(hCompiler)
      If AvailableProgramOutput(hCompiler)
        ReponseComp = ReadProgramString(hCompiler)
        Debug ReponseComp
        If ReponseComp = "READY"
          ProcedureReturn #True
        EndIf
      EndIf
    Wend
  EndIf
EndProcedure
ProcedureDLL PB_RestartCompiler()
  Protected ReponseComp.s
  WriteProgramStringN(hCompiler, "END")
  CloseProgram(hCompiler)
  ProcedureReturn PB_Connect()
EndProcedure

If PB_Connect() = #True
  Debug #True
  Debug PB_RestartCompiler()
EndIf

Posted: Sat Nov 22, 2008 5:44 pm
by Fred
Looks good.

Posted: Sun Nov 23, 2008 7:55 am
by Progi1984
Thanks :)