![]() |
|
Finding the end of a datafile |
Tomoso
Member #3,128
January 2003
![]() |
How would I go about finding out how many files are within a datafile. This is primarily for loading datafiles containing "tile gfx" within my map editor. I have a button within my map editor which allows me to load new datafiles at run time but the array of "buttons" that represent each file within the datafile needs to know how many their are, otherwise it reads to far into the datafile if I have to scroll through the objs. Thanks, Lazy Noob - Blog |
Steve Terry
Member #1,989
March 2002
![]() |
I believe it's called DAT_END ___________________________________ |
Tomoso
Member #3,128
January 2003
![]() |
And what do I do with DAT_END? I want to convert it to an integer for use with loops. I was thinking about adding an obj at the end of a datafile called "END_OBJ" or something, and when the datafiles loaded using DATAFILE *find_datafile_object(const DATAFILE *dat, const char *objectname);
If it returns null datafile is invalid, otherwise use Cheers Lazy Noob - Blog |
Michael Faerber
Member #4,800
July 2004
![]() |
From the manual: for (i=0; dat<i>.type != DAT_END; i++) { if (stricmp(get_datafile_property(dat+i, DAT_ID('N','A','M','E')), "my_object") == 0) { /* found the object at index i */ } } /* not found... */ Do you understand now how to use DAT_END? -- |
Audric
Member #907
January 2001
|
(untested) df = load_datafile("moretiles.dat"); if (! df) return -1; // error for (i=0; df<i>.type != DAT_END ; i++) { // do whatever you want with df<i> // You can choose to process only those where df<i>.type == DAT_BITMAP // df<i>.dat is a pointer to the item (ie: BITMAP *) }
|
Steve Terry
Member #1,989
March 2002
![]() |
Oh I don't know maybe it's called a manual? for (i=0; dat<i>.type != DAT_END; i++)
___________________________________ |
Tomoso
Member #3,128
January 2003
![]() |
Michael Faerber said: Do you understand now how to use DAT_END?
Yes thankyou. Lazy Noob - Blog |
|