Previous mail
Next mail
Unformatted/full headers
Overview 10 days
Subject
Date
Thread
Author
From: Waldek Hebisch
Subject: anyfile and blockwrite
Date: 19 Nov 2009, 00:53:01
Wolfgang Helbig wrote: > Hi, > > Using blockwrite with Anyfile surprises me: > > The type definitions are: > byteFile= file of packed record b: eightbits end; > eightbits = 0..255; > > And the variables: > dvibuf: array [0..800] of eightbits; > dvifile: byteFile; > > > The file is opened by rewrite(dvifile, filename) and then written by > procedure writeit(f: anyfile); > begin blockwrite(f, dvibuf[0..211], 212) end; > > I expected to get a file with 212 bytes like this one: > osx $ od -tu1 expected > 0000000 247 2 1 131 146 192 28 59 0 0 0 0 3 232 27 32 > > But instead I get this file, the length is correct, but every byte occupies 32 bit, the higher bytes are not written at all. > > osx $ od -tu1 unexpected > 0000000 247 0 0 0 2 0 0 0 1 0 0 0 131 0 0 0 > 0000020 146 0 0 0 192 0 0 0 28 0 0 0 59 0 0 0 > > All this is done with gpc version 20070904 on Mac OS X 10.6.2. > > I want to make minimal use of GPC extensions, thats why I didn't use the GPC byte for eight_bits or didn't use > packed on subranges. I'd prefer to use packed file of eightbits instead, but GPC ignores packed for files. > > And then I'd like to use buffered output without changing the source file! > Declaration for 'dvifile' does not matter. 'blockwrite' simply writes content of 'dvibuf', exactly how it is stored in memory. AFAICS you want: dvibuf: packed array [0..800] of eightbits; GPC simply stores each record in a separate machine word. Compare 'SizeOf(dvibuf)' with both your original declaration and with packed added.
Previous mail
Next mail
Unformatted/full headers
Overview 10 days
Subject
Date
Thread
Author
| Author | Subject | Date |
|---|---|---|
| Wolfgang Helbig | anyfile and blockwrite | 18 Nov 2009, 20:31:34 |
Note: This page contains information that does not originate from the owner of this web site, but from the authors of the mails archived. The owner of this web site is not responsible for the content of such information. Any use of that infomation requires the consent of the respective author.
Where WWW addresses (URLs) in the mails archived are marked as hyperlinks, this is only for the comfort of the reader. The content of the web pages linked to like this does not necessarily reflect the opinion of the owner of this web site or of the authors of the mails archived. The owner of this web site is not responsible for the content of such web pages. Those pages are explicitly not to be considered as part of the content of this page, but merely as references.
This page was created by Crystal 0.999 (Linux 2.4.27/i686).