CreateProcess problem

BlitzPlus Forums/BlitzPlus Programming/CreateProcess problem

schilcote(Posted 2009) [#1]
I am writing a blitz program which utilizes the CreateProcess command to talk to other programs. Oddly, the program hangs alot. I wrote some test code:

	Frotz=CreateProcess("cmd.exe")
Print frotz

Stop

While Not Eof(Frotz)

	Repeat

	lin$=""
	
	Repeat
		byte=ReadByte(frotz)
		lin$=lin$+Chr$(byte)
	Until(byte=13 Or byte=0)
	
	Write lin$
	
	Until(lin$="" Or lin$=Chr$(14))
	

	WriteLine(Frotz,Input$(""))
	
	Delay (500)
Wend

	WaitKey
	End


(CMD.exe is just for the test program, that's not the program I'm going to be using in the real program.)

I tracked the problem down with the debugger. Apparently, when it tries to ReadByte right after the > in the command line, the program hangs.

Is this because you can't read beyond the end of available data on a CreateProcess stream?


schilcote(Posted 2009) [#2]
Should I take the complete silence in this topic as a yes?


em22(Posted 2009) [#3]
i don't think CreateProcess will do what you want it to.

I use this method :

a=CreateProcess (f$)


While Not Eof(a) : g$=ReadLine (a)
DebugLog (g$)

Wend