Jump to content
Sign in to follow this  
Al Jones

Reading Binary file into Struct

Recommended Posts

Al Jones

I'm either looking for the wrong thing or ...

I have another program in VB.net that reads a font file (TTF / TTC) and extracts information for the various tables.

Is it possible in autoit to do the equivalent of C's fseek(), fread()??

If it can, would you point me to the functions, I don't see them.

I've read a lot of discussion about struct's in the forum, but don't see them defined as a (argh) variable type (realizing that one uses a struct to define a variable). What I'd like to do, I think, is to define an array of structs -- possible??

Unless you can point me to something that does similar, I'd be happy with the requisite referenses.

//al

Share this post


Link to post
Share on other sites
SmOke_N

fread is FileRead

fseek you can use the Winapi.au3 library to change file positions, but most will use StringRegExp()/StringInStr() to get their positions within the file on a specific string manipulation query.

Structs can be type defined:

typedef struct {
    char sz_example[20];
    int   i_example;
} t_struct;

Can be translated like:

$t_struct = DllStructCreate("char sz_example[20]; int i_example")
Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
Al Jones

Let's translate my request a little, I'm looking at reading in offsets (binary data) which points to some other table in the file - almost without exception this is all strict binary (non-ascii) data. That data is mostly contained in a struct - though I suppose I could take a previously read file offset and add the offset to the element in the structure to read that particular field.

Just wondering if this could be done - reasonably - in Autoit??

//al

Share this post


Link to post
Share on other sites
maqleod

Let's translate my request a little, I'm looking at reading in offsets (binary data) which points to some other table in the file - almost without exception this is all strict binary (non-ascii) data. That data is mostly contained in a struct - though I suppose I could take a previously read file offset and add the offset to the element in the structure to read that particular field.

Just wondering if this could be done - reasonably - in Autoit??

//al

I've looked for this same thing because I'm used to C, but no, autoit does not really have the same functions. _WinAPI_SetFilePointer(), _WinAPI_WriteFile(),_WinAPI_ReadFile() are the closest you are going to get.


[u]You can download my projects at:[/u] Pulsar Software

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.