Reading binary data

Hi all,
I’m trying to read a file which is described in the very limited documentation as ‘a binary file’.I have no experience with binary files and I’m poking in the dark a bit.
The only documentation I can find on it is https://code.google.com/p/puz/wiki/FileFormat ; a sample file is at http://herbach.dnsalias.com/Jonesin/jz131212.puz . I’m trying to extract the info about the width and height from the start of it, which may well be stored as binary data.
Can anyone help me on how to decode it, so I can read the stuff at the start of the file?
Thanks!
Hamish

One way to handle this is to create a structure with the correct integer/long etc. definitions, and then do a read into this.
You have to take care of the littleendian property (hint).

Start would be:

Checksum as int16
FileMagic as string * 11
Null1String as string * 1 ’ because you might not use the 0-termination

greetings

Hm. Thanks, Rolf, that looks promising; I’ve managed to get the checksum and FileMagic out, but after that I’m baffled - it seems to return random strings, strange integers and accented characters.
Any further pointers very gratefully received; it’s not something I’ve ever done before…
Thanks,
Hamish

Just has a quick look at this…

Here is a hexdump of the first 256 bytes…
The 1st 4 digits of each line are the start address of the line,
then the 16 bytes ofeach line is shown in hex, then Ascii with non-printables as dot…

0000 92 0D 41 43 52 4F 53 53 26 44 4F 57 4E 00 02 DA ..ACROSS&DOWN... 0010 4B C7 1C 99 9B 41 CF 18 31 2E 32 63 00 00 00 00 K....A..1.2c.... 0020 EC EE 18 00 00 00 00 00 78 B8 8E 04 0F 0F 4C 00 ........x.....L. 0030 01 00 00 00 4A 45 54 4C 49 2E 55 52 41 4C 2E 53 ....JETLI.URAL.S 0040 4E 41 47 42 52 4F 41 44 2E 4E 55 4B 45 2E 4D 45 NAGBROAD.NUKE.ME 0050 54 41 41 49 52 44 49 4D 45 42 41 47 2E 45 45 4C TAAIRDIMEBAG.EEL 0060 53 52 43 53 2E 44 45 53 49 2E 41 55 4C 44 2E 2E SRCS.DESI.AULD.. 0070 2E 48 4F 54 4E 49 43 4B 45 4C 50 4C 41 54 45 2E .HOTNICKELPLATE. 0080 2E 2E 4F 54 52 4F 2E 54 41 50 2E 4C 4F 57 41 50 ..OTRO.TAP.LOWAP 0090 53 45 2E 2E 2E 43 41 47 45 2E 4F 53 4F 46 45 45 SE...CAGE.OSOFEE 00A0 44 51 55 41 52 54 45 52 42 41 43 4B 4C 41 58 2E DQUARTERBACKLAX. 00B0 55 4E 4C 56 2E 2E 2E 55 4E 41 53 41 52 43 2E 41 UNLV...UNASARC.A 00C0 53 49 2E 45 41 53 54 2E 2E 2E 43 4C 4F 43 4B 50 SI.EAST...CLOCKP 00D0 45 4E 4E 59 57 49 53 45 2E 2E 2E 4D 41 59 4F 2E ENNYWISE...MAYO. 00E0 49 44 45 41 2E 45 4C 4F 43 48 45 52 2E 49 4E 53 IDEA.ELOCHER.INS 00F0 45 52 54 43 4F 49 4E 4D 4F 44 45 2E 4C 45 41 52 ERTCOINMODE.LEAR

According to the spec width is at offset 2c and is one byte long and height is in the byte after that
Those bytes are both 0F, ie: 15

Hi Chris,

Thanks for this - that makes sense (it’s a 15x15 grid). I’ll give it a shot!

Cheers,

Hamish

After the header it looks like the 180 (15x15) chars of the puzzle answers, with dot characters where the blocks go,
then a similar chunk for the player’s current state, with hyphens for non-filled in bits, which is all of them in this case.
After that you get null-terminated strings for items mentioned in the Strings section, ie:
Title, Author, Copyright ( an empoty string in this case, so just thr terminator ) then all the clues.
Thst’s all I can see in this .puz file.