Posted: Sun Apr 30, 2006 4:37 pm
Ha, you just have to wait until the buffer gets flushed and it works (about 15 secs here). You have to move the mouse over the window as you used WaitWindowEvent().
http://www.purebasic.com
https://www.purebasic.fr/english/
Here DOES NOT print anything , using the Project2.exe file above neither using quickbasic piper.exeFred wrote:Weird, it definitely print the numbers here. Can anyone else confirm ? (using the Project2.exe file above).
Stop talking to me like i do not know what i am doing.Trond wrote:1. Hmm, what does the Ln in WriteLn() mean?freak wrote:The reason that the command is line-based is for ease of use. Most console
output is line-based, so it makes more sense to read it in that manner as well.
To prevent this, ReadProgramData() can be used.
2. ReadProgramData() does not fix the problem.
So here you have the reason. The writer of the program is responsible to write it in the correct wayMS PlatformSDK wrote:Both WriteConsole and WriteFile can be used for console I/O. While WriteConsole supports writing Unicode characters to a console screen buffer, WriteFile does not. However, WriteConsole fails if it is used with a standard handle that is redirected to a file.
Code: Select all
OpenWindow(0, 0, 0, 512, 384, "", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
CreateGadgetList(WindowID(0))
EditorGadget(0, 10, 10, 492, 364)
Pid = RunProgram("b:\project2.exe", "", "", #PB_Program_Open | #PB_Program_Read)
Repeat
Select WaitWindowEvent(10)
Case #PB_Event_CloseWindow
Break
EndSelect
size = AvailableProgramOutput(Pid)
If size > 0
*buffer = AllocateMemory(size)
If *buffer
readsize = ReadProgramData(Pid, *Buffer, size)
String$ = ReplaceString(PeekS(*Buffer, readsize), Chr(13), "#"+Chr(13))
AddGadgetItem(0, -1, String$)
FreeMemory(*buffer)
EndIf
EndIf
ForEver
KillProgram(Pid)
CloseProgram(Pid)
freak wrote:2. Why the QB program does not work:
I did not test this any further, but i would simply guess that communication
with real dos programs using the Win32 pipe mechanism is not working.
I don't think that this is worth investigating any further.
No bug? You say that communication with real dos programs using the Win32 pipe mechanism is not working, and you add "there is no bug"?freak wrote:The conclusion:
There is no bug. PB does the stuff correctly. (In fact, more correct than most Win32 programs
out there, as i did quite some research on this topic)
And then you can freely say: "There is no bug", but not before.communication with real dos programs using the Win32 pipe mechanism is not working.
Thats just the console output. It is different from what is sent on the pipe.thefool wrote:project2.exe prints numbers on new lines and in a correct delay.
so i confirm the delphi program works on winxp pro sp2.
That's not a total true, because as you know, WinXP includes a built-infreak wrote:Dos programs do not even run anymore on WinXP...
Are you sure of that ? Aren't the vast majority of console programs in the Win32/Console format ?Psychophanta wrote:Well, that's right.
The matter is that console programs (from which the data output can be read using PB) are usually in DOS, win16 (i.e 3.11), drdos, ...
I tough you knewPsychophanta wrote:Uffh! dunno, but i'd say that most are DOS.