Does anyone have an example of using this? I tried to pipe ipconfig's output to findstr (on Windows) based on this thread:#PB_Program_Connect: Connect another programs output to this programs input.
When using the #PB_Program_Connect flag, another program must have been started before with #PB_Program_Open and #PB_Program_Read. The number returned when running this program must be passed as the 'SenderProgram' parameter to RunProgram(). The output of the sender program will be sent directly to the input of the now executed program. Several programs may be connected in this way, to 'pipe' data through that group of connected programs.
viewtopic.php?f=13&t=73438
Here is my test code, can we get #PB_Program_Connect working, or is this a Bug Report?
Code: Select all
CompilerIf (#PB_Compiler_ExecutableFormat <> #PB_Compiler_Console)
;CompilerError "Please compile in Console mode" ; Maybe Console mode is needed?
CompilerEndIf
CompilerIf (#PB_Compiler_OS <> #PB_OS_Windows)
CompilerError "This example is designed for Windows"
CompilerEndIf
If OpenConsole() ; Is OpenConsole() needed?
Flags = #PB_Program_Open | #PB_Program_Read | #PB_Program_Hide
*ipconfig = RunProgram("ipconfig", "/all", "", Flags)
;Debug *ipconfig
Flags = #PB_Program_Open | #PB_Program_Read | #PB_Program_Hide | #PB_Program_Connect ; What flags are needed with Connect?
*findstr = RunProgram("findstr", "/I ipv4", "", Flags, *ipconfig)
;Debug *findstr
While (ProgramRunning(*ipconfig) Or ProgramRunning(*findstr))
If AvailableProgramOutput(*ipconfig) ; Shouldn't the ipconfig output automatically go to findstr?
Output.s + ReadProgramString(*ipconfig) + #CRLF$
EndIf
If AvailableProgramOutput(*findstr)
Output2.s + ReadProgramString(*findstr) + #CRLF$
EndIf
Delay(0)
Wend
Debug "-------------- ipconfig output:"
Debug Output
Debug "-------------- findstr output:"
Debug Output2
CloseProgram(*findstr)
CloseProgram(*ipconfig)
CloseConsole()
EndIf