Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2000
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Q: How to avoid WriteBinary to write an extra nul after each call ?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg25333] Re: Q: How to avoid WriteBinary to write an extra nul after each call ?
  • From: Albert Retey <albert.retey at visualanalysis.com>
  • Date: Sat, 23 Sep 2000 03:35:56 -0400 (EDT)
  • Organization: Visual Analysis
  • References: <8q77vq$t6d@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi Claudius,

> I would like to write some peaces of data in a file.
> Now I wonder that WriteBinary appends an nul-character after each
> call.

It does so only if you are storing strings, as the documentation says,
it stores strings as null-terminated as is common practice. This is to
mark the end of each string. It will not be done when storing numbers...

> How can I avoid this behaviour?

Don't write strings :-). You could also concatenate all your strings
within mathematica to one long string and then just store this long
string, this would only write one extra string-termination-character and
maybe also be a lot faster. (In general writing big blocks is a usually
a lot faster...).

Still the question arises why you want to store strings in a binary file
at all?
The main advantage of binary files you will see when storing large
arrays (lists that is in mathematica) of numeric data, I guess?

Also look into the online-documentation, I think the zero-terminated
strings is in there... 

Cheers
Albert


  • Prev by Date: Re: matrix indices
  • Next by Date: Re: Point inside a plygon? and PointInsidePolyhedronQ
  • Previous by thread: Q: How to avoid WriteBinary to write an extra nul after each call ?
  • Next by thread: Simultaneous equations