Dennis
Using what? Since this is a MSDOS group, though I noticed
that you are coming from a NT Batch group, you can create
a zero length file many ways.
It has been a while, but if you uses DOS's Create_File
service call, then write zero bytes (CX = 0) to it,
then close is, won't that create a zero byte file?
IIRC, you *have* to call the Write_File service call
or DOS won't create the file entry. Just calling
the Create_File/Close_File service calls won't do it.
However, it have been a while so I may be wrong.
Ben
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Forever Young Software
http://www.frontiernet.net/~fys/index.htm
http://www.frontiernet.net/~fys/collections.htm
To reply by email, please remove the zzzzzz's
Batteries not included, some assembly required.
> "Dennis Halver" <ha...@persrec.com> wrote in message
> news:4a526f74$0$32682$9b4e...@newsspool2.arcor-online.net...
> > How can I create a file with 0 byte length?
> >
> > Dennis
>
> Using what? Since this is a MSDOS group, though I noticed
> that you are coming from a NT Batch group, you can create
> a zero length file many ways.
>
> It has been a while, but if you uses DOS's Create_File
> service call, then write zero bytes (CX = 0) to it,
> then close is, won't that create a zero byte file?
>
> IIRC, you *have* to call the Write_File service call
> or DOS won't create the file entry. Just calling
> the Create_File/Close_File service calls won't do it.
>
> However, it have been a while so I may be wrong.
>
> Ben
I think it's not necessary, Ben -- at least it isn't here in
MSDOS 6.22. Maybe what you are recalling is the way to truncate
an existing file to zero bytes? In that case, you just seek to
the point in the file you want to make EOF (or in this case, the
beginning) and write zero bytes.
That said, I spent a few minutes playing around at the DOS prompt
and all that seems necessary is to run some command that writes
nothing to STDOUT and redirect to a file. For example:
echo. > tempfile.$$$
del tempfile.$$$ > zerosize.fil
creates a zero length file.
Dennis, why do you want a zero length file? Would a directory
entry suffice? Or even a volume label if you only need one such
and don't mind it being in the root dir.
Pete
--
"We have not inherited the earth from our ancestors,
we have borrowed it from our descendants."
They are used as flags in batch files. There are a few other, rarely
encountered, uses as well. Mostly they are used by batch files to indicate
that some process (usually the batch file itself) is running and
additional instances should self abort. They are also used to signal when
a file is in use - sort of like a write lock - to prevent or allow other
batch files to use the file or wait until it's free.
--
T.E.D. (tda...@mst.edu)
> That said, I spent a few minutes playing around at the DOS prompt
> and all that seems necessary is to run some command that writes
> nothing to STDOUT and redirect to a file. For example:
>
> echo. > tempfile.$$$
> del tempfile.$$$ > zerosize.fil
>
> creates a zero length file.
rem > tempfile.$$$
is one easy way; REM doesn't display anything to stdout. Even easier,
using 4DOS, is
> tempfile.$$$
i.e. redirect output without executing any command!
--
Charles Dye
> rem > tempfile.$$$
That doesn't work in XP. I've never seen anyone actually use it, though
it might work in Real DOS.
A few years ago, I experimented with all the usual methods and found that
only one works in all the MS OSs:
type nul > file
--
T.E.D. (tda...@mst.edu)
It does. (I'm reading this in an MS-DOS group....)
> A few years ago, I experimented with all the usual methods and found that
> only one works in all the MS OSs:
>
> type nul > file
Very nice. That also works in 4DOS, Take Command, and the DR-DOS /
OpenDOS implementation of COMMAND.COM. I suppose the NUL device must
always return EOF on read.
--
Charles Dye ras...@highfiber.com
Odd... I should work.
But mine (XP SP3 CMD.EXE & COMMAND.COM) also don't work.
goto nowhere > file
works though.
XP SP3 isn't MS-DOS.
--
Charles Dye
OP, if you are out there and reading this message, please do us the
courtesy of allowing the multipost to do what it was intended to do,
or at the very least indicate in the original post that you've set
followups to a specific group.
--
Zaphod
No matter where you go, there you are!
> I suppose the NUL device must
> always return EOF on read.
It does ... more or less.
--
T.E.D. (tda...@mst.edu)
> XP SP3 isn't MS-DOS.
True, but the original message had Followup-to: set to alt.msdos.batch.nt.
--
T.E.D. (tda...@mst.edu)
> >> On Tue, 07 Jul 2009 11:24:24 -0700, raster wrote:
> >>> rem > tempfile.$$$
> >> That doesn't work in XP. I've never seen anyone actually use it, though
> >> it might work in Real DOS.
> >
> > It does.
> Odd... It should work.
> But mine (XP SP3 CMD.EXE & COMMAND.COM) also don't work.
> goto nowhere > file
> works though.
*** In DR-DOS, so does:
GOTO > FILE
A syntax error message appears, but the zero-byte file is created.
Richard Bonner
http://www.chebucto.ca/~ak621/DOS/