From: Yoni on
I’m working on a script that occasionally sends output to a serial port. But sometimes I want to test other aspects of it on computers where I know the fopen(port) command will fail. What I prefer to do in those cases is to then assign a dummy filehandle to the port variable such that any further calls to fwrite(port, value) will do nothing. On Mac/Unix, I could just say
port = fopen('/dev/null', 'w');

but this won’t work on Windows. I know I could just write to a real file and delete it later, but I don’t want to access the disk when I don’t have to. I’d also prefer not to use the stdout or stderr handles, which would litter my console output with junk characters.

Is there a Windows or cross-platform equivalent of /dev/null ? Or a way to make file IDs that actually point to a RAM buffer?
From: Walter Roberson on
Yoni wrote:

> Is there a Windows or cross-platform equivalent of /dev/null ?

Yes, the device named NUL:
From: Yoni on
Can you elaborate? I see that I can do things at the Windows command prompt that involve redirecting to nul, but I don’t see how I can access it as a file identifier in Matlab.
From: Yoni on
Oops, never mind. it finally occurred to me that the ':' was part of the name when I re-read that after posting.

Walter Roberson <roberson(a)hushmail.com> wrote in message <hv5s1r$2ud$1(a)canopus.cc.umanitoba.ca>...
> Yoni wrote:
>
> > Is there a Windows or cross-platform equivalent of /dev/null ?
>
> Yes, the device named NUL: