Hi Spriggsy
What an excellent solution using pipes. I have tried using these in the pass but always failed, never understood what bits to twiddle.
I downloaded the latest (05/11/2020 08:05) version of your pipecom library and it failed to compile on Windows 8.1.
No big deal, change file pipecom.bas to:
comm = pipecom$("dir /b *.BAS")
Compiled and run with no issues.
Looking at pipecom.h
Lines "int first;" and "int last;" are leftover code? delete these not required.
The small buffer size does not look right, proposal:
Replace this code:
char buf
[2] = { };
//I know
, the buffer
is small but I had
to in order
to work with things like PING
DWORD dwRead = 0;
while (ReadFile
(hStdOutPipeRead
, &buf
, 2, &dwRead
, NULL
) && dwRead
) {
buf[dwRead] = '\0';
}
With the following code:
//Note: ReadFile will
return when buffer
is full
, or pipe
is closed
#define BUFFSZ
4096 //Seems
to work here. Better
to place at top of code
char buf
[BUFFSZ
+ 1];
//+1 Space
for null terminator
while (ReadFile
(hStdOutPipeRead
, buf
, BUFFSZ
, &dwRead
, NULL
)) {
buf[dwRead] = '\0';
}
Not sure what the issue you had with PING (buf[2]) however with the above changes I tried this code:
comm = pipecom$("ping google.com")
it works.
All the best.