Missed output from progrum run by RunProgram?
Posted: Fri Jan 30, 2026 7:01 pm
This example is from the help:
https://www.purebasic.com/documentation ... ogram.html
What happens if the program spits out output right before the wend? Wouldn't it be missed? Even more, I usually us a while construct within the ProgrammRunning-loop to get the output (unrelated to my question, but maybe better timing).
Code: Select all
; Executes the PB compiler with the /? option and displays the output
;
Compiler = RunProgram(#PB_Compiler_Home+"compilers/pbcompiler", "-h", "", #PB_Program_Open | #PB_Program_Read)
Output$ = ""
If Compiler
While ProgramRunning(Compiler)
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$)What happens if the program spits out output right before the wend? Wouldn't it be missed? Even more, I usually us a while construct within the ProgrammRunning-loop to get the output (unrelated to my question, but maybe better timing).