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 0000020 84 101 88 32 111 117 116 112 117 116 32 50 48 48 57 46 0000040 49 49 46 49 56 58 49 57 49 57 139 0 0 0 1 0 0000060 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 * 0000120 0 0 0 255 255 255 255 141 159 242 0 0 142 160 2 131 0000140 51 218 141 160 253 134 204 38 141 145 20 0 0 243 0 75 0000160 241 96 121 0 10 0 0 0 10 0 0 0 5 99 109 114 0000200 49 48 171 104 97 108 108 111 142 142 159 24 0 0 141 146 0000220 0 232 96 163 49 142 140 248 0 0 0 42 1 131 146 192 0000240 28 59 0 0 0 0 3 232 2 155 51 218 1 213 193 71 0000260 0 2 0 1 243 0 75 241 96 121 0 10 0 0 0 10 0000300 0 0 0 5 99 109 114 49 48 249 0 0 0 151 2 223 0000320 223 223 223 223 0000324
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 0000040 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0000060 3 0 0 0 232 0 0 0 27 0 0 0 32 0 0 0 0000100 84 0 0 0 101 0 0 0 88 0 0 0 32 0 0 0 0000120 111 0 0 0 117 0 0 0 116 0 0 0 112 0 0 0 0000140 117 0 0 0 116 0 0 0 32 0 0 0 50 0 0 0 0000160 48 0 0 0 48 0 0 0 57 0 0 0 46 0 0 0 0000200 49 0 0 0 49 0 0 0 46 0 0 0 49 0 0 0 0000220 56 0 0 0 58 0 0 0 49 0 0 0 57 0 0 0 0000240 50 0 0 0 51 0 0 0 139 0 0 0 0 0 0 0 0000260 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0000300 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 * 0000320
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!
Greetings, Wolfgang
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.