Discussion:
DOS 5 QBASIC (in XPsp3) write to win32 named pipe ?
(too old to reply)
R.Wieser
2024-03-07 11:30:47 UTC
Permalink
Hello all,

I'm using QBasic from DOS 5 in an XPsp3 cmd.exe console, and am trying to
write to a file which is actually a named pipe in a Win32 program.

The thing is that it works when, in QBASIC, I open the file "for binary" and
"put" the data. However, when I open the file "for output" than I can see,
in the Win32 program, the data coming in from the pipe, but the QBASIC
program than throws an "invalid record number" on the "close #hPipe" line -
after which I cannot re-run, save or exit the program (all of which again
show the "invalid record number" error).

tl;dr:
Has anyone ever tried to let QBASIC open a named pipe and wtite to it as if
its a regular text file ? If so, how/as what should I, in the Win32
program, open the named pipe ?

Regards,
Rudy Wieser
R.Wieser
2024-03-07 13:40:33 UTC
Permalink
Post by R.Wieser
Has anyone ever tried to let QBASIC open a named pipe and wtite to it as
if its a regular text file ? If so, how/as what should I, in the Win32
program, open the named pipe ?
To text/check I just wrote a small DOS program using INT 21h calls to open
(AX=3D01h), write to(AH=40h) and close (AH=3Eh) the pipe. As far as I can
tell that works without a problem.

IOW, the problem might be QBASIC ...

Regards,
Rudy Wieser
Auric__
2024-03-07 17:16:11 UTC
Permalink
Post by R.Wieser
Post by R.Wieser
Has anyone ever tried to let QBASIC open a named pipe and wtite to it as
if its a regular text file ? If so, how/as what should I, in the Win32
program, open the named pipe ?
To text/check I just wrote a small DOS program using INT 21h calls to open
(AX=3D01h), write to(AH=40h) and close (AH=3Eh) the pipe. As far as I can
tell that works without a problem.
IOW, the problem might be QBASIC ...
Probably. I've never tried doing anything remotely like what you're trying to
do, but QBasic is somewhat limited in what it can and cannot do (although I
don't think it's a QBasic-vs-QuickBASIC thing) but also, it predates 32-bit
Windows by several years. Does your program *need* to be in QBasic? You could
try it in FreeBASIC using '-lang fblite' or even '-lang qb' and see what
happens. (You could probably also try QB64 but I can't help you there.)
--
If you're aware you exist, then you do.
R.Wieser
2024-03-07 18:30:00 UTC
Permalink
Auric,
Post by Auric__
Does your program *need* to be in QBasic?
Its not about a program, but about extending QBasic's capabilities - so it
can easily communicate with a Win32 program. How I'm going to use that is
step two (although I already have an idea or two)
Post by Auric__
but QBasic is somewhat limited in what it can and cannot do
I know. But it can write to a file. It just happens not to like the
pipe-file I'm offering it.

... Which I took as me having created the pipe in a wrong mode (hence the
question), but I'm now doubting that as I have zero problems when doing the
same writing with a standard 16-bit DOS executable.

And mind you, I'm a hobbyist. As nobody is paying me for my time I'm allowed
to squander it on figuring stuff like this out. :-)

Regards,
Rudy Wieser
JJ
2024-03-08 05:23:15 UTC
Permalink
Post by R.Wieser
Hello all,
I'm using QBasic from DOS 5 in an XPsp3 cmd.exe console, and am trying to
write to a file which is actually a named pipe in a Win32 program.
The thing is that it works when, in QBASIC, I open the file "for binary" and
"put" the data. However, when I open the file "for output" than I can see,
in the Win32 program, the data coming in from the pipe, but the QBASIC
program than throws an "invalid record number" on the "close #hPipe" line -
after which I cannot re-run, save or exit the program (all of which again
show the "invalid record number" error).
Has anyone ever tried to let QBASIC open a named pipe and wtite to it as if
its a regular text file ? If so, how/as what should I, in the Win32
program, open the named pipe ?
Regards,
Rudy Wieser
Pipe (named or not) is a character device. It has no total data size, and is
not seekable. IOTW, data size query and seek operations are not applicable
to character device.

Q/BASIC's binary file mode is a random-access file mode which treats file as
a block device, instead of a character device. But random-access file mode
does I/O seek as well as querying the total data size.
R.Wieser
2024-03-08 10:18:53 UTC
Permalink
JJ,

I do not know what your game is, but I disagree with most anything you said
there.

It also doesn't help that you're rather ambigue and seem to be making a
claim that opening a file using a certain open mode can turn it from a
character device into a block device.

Its almost as if you're out to sow confusion ...

Regards,
Rudy Wieser
JJ
2024-03-09 07:59:58 UTC
Permalink
Post by R.Wieser
JJ,
I do not know what your game is, but I disagree with most anything you said
there.
It also doesn't help that you're rather ambigue and seem to be making a
claim that opening a file using a certain open mode can turn it from a
character device into a block device.
Its almost as if you're out to sow confusion ...
Regards,
Rudy Wieser
Then I don't think you know the difference between the two.
R.Wieser
2024-03-09 08:56:35 UTC
Permalink
JJ,
Post by JJ
Then I don't think you know the difference between the two.
Than now is your chance to educate me to what (you think) a "character
device" and "block device" are.

There is a possibility that you and I are not thinking about the same thing.
Maybe, after having heard your definitions of them I would be able to
understand what you wrote.

Regards,
Rudy Wieser
R.Wieser
2024-03-12 09:14:21 UTC
Permalink
JJ,
Post by R.Wieser
Post by JJ
Then I don't think you know the difference between the two.
Than now is your chance to educate me to what (you think) a "character
device" and "block device" are.
Too bad that you didn't respond. You might have had some knowledge I am not
(yet) aware of (and possibly relevant to the question I asked). Now I will
never know ...

JJ, what happened to you ? You're so much different from the one I knew
from even just a year ago that you seem to be a different person. :-|

Regards,
Rudy Wieser

R.Wieser
2024-03-09 09:14:31 UTC
Permalink
Post by R.Wieser
The thing is that it works when, in QBASIC, I open the file "for binary"
and "put" the data.
After more testing it looks like that even the above "for binary" method is
not fully stable : while I can run a QBasic program using the above method,
re-running it (SHIFT F5) works when talking to one Win32 (GUI) program, but
the second file-opening fails when talking to another Win32 (console)
program.

As a 16-bit DOS program didn't seem to suffer from the same I loaded the INT
21h open, write and close functions as binary blobs into the QBasic program
and used them with "CALL absolute()". It now seems to function quite well,
regardles of the used Win32 "server" program (though the stress-test still
needs to be done).

Question :

Although accessing arguments in the binary blob that where provided to the
"CALL absolute()" function works, I've never been able to check the
arguments type (integer, string, etc). Does anyone remember/know how to do
that ?

Regards,
Rudy Wieser
Loading...