Mail Archives: djgpp/1998/06/01/17:45:45
Chia writes:
>I saw in the grabber that you can have a datafile object within an
>datafile.
>
> How would I get data out of the second datafile?
From the Allegro grabber.txt file:
If a datafile contains nested child datafiles, the header will prefix
the names of objects in the sub-files with the name of their parent
datafile. It will also define a count of the number of objects in the
child file, which may be useful if for example the child datafile
contains several bitmaps which form a 'run' animation, and you want your
code to automatically adjust to the number of frames in the datafile.
For example, the datafile:
"FILE" - NESTED_FILE
|- "BMP" - A_BITMAP
|- "FONT" - A_FONT
"DATA" - SOME_DATA
"DATA" - SOME_MORE_DATA
produces the header:
#define NESTED_FILE 0 /* FILE */
#define NESTED_FILE_A_BITMAP 0 /* BMP */
#define NESTED_FILE_A_FONT 1 /* FONT */
#define NESTED_FILE_COUNT 2
#define SOME_DATA 1 /* DATA */
#define SOME_MORE_DATA 2 /* DATA */
The main datafile contains three objects (NESTED_FILE, SOME_DATA, and
SOME_MORE_DATA) with consecutive indexes, while the child datafile
contains the two objects A_BITMAP and A_FONT. To access these objects
you need to reference both the parent and child datafiles, eg:
DATAFILE *dat = load_datafile("whatever.dat");
DATAFILE *nested = (DATAFILE *)dat[NESTED_FILE].dat;
FONT *thefont = (FONT *)nested[NESTED_FILE_A_FONT].dat;
--
Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/
"Miracles are nothing if you've got the wrong intentions" - Mike Keneally
- Raw text -