with some programs it is not possible to catch stdout and stderr if #PB_PROGRAM_WRITE is also applied.
For example: python
Code: Select all
EnableExplicit
Define Python.i, State.i, Err$, OutLen.i, *Buffer
Python = RunProgram("python.exe", "-u -", GetPathPart(ProgramFilename()), #PB_Program_Open|#PB_Program_Read|#PB_Program_Write|#PB_Program_Error|#PB_Program_Ascii)
;Python = RunProgram("python.exe", "-u -", GetPathPart(ProgramFilename()), #PB_Program_Open|#PB_Program_Read|#PB_Program_Error|#PB_Program_Ascii)
If Python
While ProgramRunning(Python)
OutLen = AvailableProgramOutput(Python)
If OutLen
*Buffer = AllocateMemory(OutLen, #PB_Memory_NoClear)
If *Buffer
If ReadProgramData(Python, *Buffer, OutLen) = OutLen
Debug "stdin: " + PeekS(*Buffer, OutLen, #PB_Ascii)
If State = 0
Debug "quit()"
WriteProgramStringN(Python, "quit()", #PB_Ascii)
State + 1
EndIf
EndIf
FreeMemory(*Buffer)
EndIf
EndIf
Err$ = ReadProgramError(Python, #PB_Ascii)
If Len(Err$)
Debug "stderr: " + Err$
EndIf
Wend
Debug ProgramExitCode(Python)
CloseProgram(Python)
EndIf
PB 5.50 x86 on win10 x64
Btw. small python:
https://www.python.org/ftp/python/3.5.2 ... -win32.zip
unzip it and save the PB code in the same directory.
Bernd