It doesn't allow me to control the called routine subprog.pb. Instead, the called routine doesn't respond at all. subprog.pb works fine if I run it directly. It also works fine if I change the calling programme mainprog.pb to remove | #PB_Program_Write. The intention is to accept input and display it back, until the word end is entered. Therefore in mainprog.pb I'm trying to send end to the called routine. Instead subprog.pb sits there waiting, and because I've used the | #PB_Program_Write flag, it no longer accepts keyboard input from me.
subprog.pb
Code: Select all
OpenConsole()
PrintN("Sub-programme now running")
While exitflag = #False
inpval.s = Input()
PrintN("Entered : " + inpval.s)
If inpval.s = "end"
exitflag = #True
EndIf
Wend
Code: Select all
Compiler = RunProgram("j:\pbtest\subprog.exe", "", "", #PB_Program_Open | #PB_Program_Read | #PB_Program_Write)
Output$ = ""
If Compiler
While ProgramRunning(Compiler)
WriteProgramStringN(compiler,"end",#PB_Ascii)
If AvailableProgramOutput(Compiler)
Output$ + ReadProgramString(Compiler) + Chr(13)
EndIf
Wend
Output$ + Chr(13) + Chr(13)
Output$ + "Exitcode: " + Str(ProgramExitCode(Compiler))
CloseProgram(Compiler) ; Close the connection to the program
EndIf
MessageRequester("Output", Output$)