How do you get pub.freeprocess to read i/o ??

BlitzMax Forums/BlitzMax Programming/How do you get pub.freeprocess to read i/o ??

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Yes, Thanks are due. I think I understand the Readline method a bit better now. (At first I thought it was completely borked, shame on me!). It is non blocking, and sits in front of a 4k buffer. In this case pretty much all the output from these commands is available at once unless as you say it is a slow machine or a lot is going on, so it is buffered immediately and readline starts to work on the buffer, but by that time the process has finished.

Fortunately Bufferpos is exposed as a field in TPipeStream so you can check that.

SuperStrict

Framework brl.standardio
Import pub.freeprocess

Local temp_process:TProcess = CreateProcess("ipconfig /?",HIDECONSOLE)
Local temp_read:String, avail:Int

Print "started"
Repeat
	' loop until data available.  In practice of course you would be doing other things.
	Repeat 
		avail = temp_process.pipe.readavail()
		If temp_process.status()=0 Then Exit
	Until avail>0

	Print "Status "+temp_process.status()
	Print "Avail "+avail
 	
	If avail=0 Then Exit

	' get available data
	Repeat
			temp_read  = temp_process.pipe.readline()

			Print temp_process.pipe.bufferpos +" read >"+temp_read

	Until temp_process.pipe.bufferpos<=0
Forever
temp_process.close()
temp_process.terminate()
temp_process = Null
Print "ended"