CreateProcess

Archives Forums/BlitzPlus Programming/CreateProcess

cyberseth(Posted 2003) [#1]
Mark and co,

This seems to be an undocumented command. I can't find it anywhere, at least! Could you explain what this does, and any like commands?


Red(Posted 2003) [#2]
its true,its usefull
I use it for my IDE project.
It creates a stream.

format_code('
stream=CreateProcess(".......")
if stream
while not eof(stream)
print readline(stream)
wend
endif
')

Does it work like ExecFile ?
ExecFile returns a stream ?


Phil Newton(Posted 2003) [#3]
Hmm, I'm going to assume the stream contains the output from the executed program. Probably most useful for compilers.

That's just a hunch though, not had chance to actually try it.


EOF(Posted 2003) [#4]
Mark uses it in his Syntax Highlighter example.
It appears the CreateProcess() function launches a program and reads back any output that program produces:

format_code('proc=CreateProcess("c:\blitzplus\bin\blitzcc.exe +k")
If proc
DebugLog "Blitzcc output ..."
While Not Eof(proc)
ln$=ReadLine$(proc)
DebugLog ln$
Wend
Else
DebugLog "Blitzcc.exe not found"
EndIf
Notify ":-)"
End')


Koriolis(Posted 2003) [#5]
I want that in Blitz3D! Until now if I want to read the results of launching an external app I must do crappy tricks.


RexRhino(Posted 2003) [#6]
Does it read it back in realtime? Meaning that I can create a seperate program, and that program could communicate to the first via stream? Or the second program need to complete operation before the first can read the stream?

Does the stream work both ways?


semar(Posted 2003) [#7]
Interesting.. how can I make a generic program communicate through this stream ?

I tryed it running calculator, but no output has been triggered. Only, it can inform you when you close the called program, because the value red from its stream is 0.

I mean, which kind of output should be generated by the called program, in order to be red from within blitz ?

This could be extremely useful... think, just for example, a VB app that handle a database, and communicate the result of a query to a blitz app...

Any further news about this undocumented gem ?

:)

Sergio.


marksibly(Posted 2003) [#8]
Hi,

Yep, CreateProcess launches a 'console based' app and returns a stream representing its input/output.

If the app is expecting input, you can write to the stream to automatically enter lines of input using WriteLine.

If the app is generating output, you can read back from the stream to receive the lines using ReadLine.

*Note* This only works with console based apps that using stdin/stdout. Windows apps typically generate no output.

Blitz Print/Input are supposed to use stdin/stdout, but that feature is not quite working properly yet.


semar(Posted 2003) [#9]
@ Mark,
thanks a lot for your explanation.

:)

Sergio.


JoshK(Posted 2003) [#10]
I'd like to see Print working...I wanted to make a silent precompiler for use with all IDE's that would automatically include an "includes" folder, but couldn't because it can't give blitzcc's feedback back to the IDE.