[Implemented] read STDIN, STDERR from PB
[Implemented] read STDIN, STDERR from PB
Hi Fred,
Please, Please, Please can we have a PB standard way of reading STDIN & STDOUT output from an external command.... in PB3.7 (so that when you get around to updating the Linux version we get it there too!!)
I've seen that there are vaious Windows API methods, but no obvious way of doing the same on Linux.
This is quite a core function, so would be best implemented as *part* of PB.
Thanks ... Nigel
(Implemented with ReadProgramString(), ReadProgramError() and WriteProgramStrin())
Please, Please, Please can we have a PB standard way of reading STDIN & STDOUT output from an external command.... in PB3.7 (so that when you get around to updating the Linux version we get it there too!!)
I've seen that there are vaious Windows API methods, but no obvious way of doing the same on Linux.
This is quite a core function, so would be best implemented as *part* of PB.
Thanks ... Nigel
(Implemented with ReadProgramString(), ReadProgramError() and WriteProgramStrin())
Ta - N
I would really love to see this too 
Dunno how it would be implemented though, for example once the 'pipe' is open (to StdOut say...) you need some way of continuously being able to read the data from the program/script because not all output comes at once, especially if the program is performing long calculations before it sends stuff to StdOut.
Tricky! C'mon Fred do us proud

Dunno how it would be implemented though, for example once the 'pipe' is open (to StdOut say...) you need some way of continuously being able to read the data from the program/script because not all output comes at once, especially if the program is performing long calculations before it sends stuff to StdOut.
Tricky! C'mon Fred do us proud

-
- Enthusiast
- Posts: 202
- Joined: Sun Apr 27, 2003 4:44 am
- Location: Michigan, USA
- Contact:
Hi, why not just implement it as:
PB_STDIN$ and PB_STDERR$ for short inputs
and like this for big data:
openFile(#PB_STDIN,"") -or-
openFile(#PB_STDERR,"")
and just normal PB commands for reading the data:
openFile(#PB_STDIN, "")
xyz=ReadByte() -or-
xyz$=ReadString() -or-
xyz.f=ReadFloat() -etc-
closeFile(#PB_STDIN, "")
PB_STDIN$ and PB_STDERR$ for short inputs
and like this for big data:
openFile(#PB_STDIN,"") -or-
openFile(#PB_STDERR,"")
and just normal PB commands for reading the data:
openFile(#PB_STDIN, "")
xyz=ReadByte() -or-
xyz$=ReadString() -or-
xyz.f=ReadFloat() -etc-
closeFile(#PB_STDIN, "")
Ta - N
ok - how about:
openFile(#PB_STDIN, "")
Repeat:
_stdin$=_stdin$+chr(13)+ReadString()
Until Eof(#PB_STDIN)
closeFile(#PB_STDIN, "")
or:
openFile(#PB_STDERR, "")
Repeat:
_stderr$=_stderr$+chr(13)+ReadString()
Until Eof(#PB_STDERR)
closeFile(#PB_STDERR, "")
- not forgetting:
openFile(#PB_STDOUT, "")
writeStringN("Error 1234 - This function does not exist yet...")
closeFile(#PB_STDOUT, "")
openFile(#PB_STDIN, "")
Repeat:
_stdin$=_stdin$+chr(13)+ReadString()
Until Eof(#PB_STDIN)
closeFile(#PB_STDIN, "")
or:
openFile(#PB_STDERR, "")
Repeat:
_stderr$=_stderr$+chr(13)+ReadString()
Until Eof(#PB_STDERR)
closeFile(#PB_STDERR, "")
- not forgetting:
openFile(#PB_STDOUT, "")
writeStringN("Error 1234 - This function does not exist yet...")
closeFile(#PB_STDOUT, "")
Ta - N
-
- Enthusiast
- Posts: 202
- Joined: Sun Apr 27, 2003 4:44 am
- Location: Michigan, USA
- Contact:
Guys, this was a request for Linux - not for Windows (there >1 OS in the world y'know 
In the Unix world, utils usually consist of a command line processor and an optional / seperate Graphical Front End. This makes STDIN/OUT/ERR a simple but also very powerful and flexible means of passing complex / large amounts of data for further processing.
There's also no issue of "How do I pass *this* message to *that* application " and changing API specs - it just works transparently...

In the Unix world, utils usually consist of a command line processor and an optional / seperate Graphical Front End. This makes STDIN/OUT/ERR a simple but also very powerful and flexible means of passing complex / large amounts of data for further processing.
There's also no issue of "How do I pass *this* message to *that* application " and changing API specs - it just works transparently...
Ta - N