there is something strange i can't get datafile object's name....
sj971059

my test code :

1#include <allegro.h>
2int main(void)
3{
4 DATAFILE* dfile;
5 BITMAP* backbuffer;
6 const char *name;
7 allegro_init();
8 install_keyboard();
9 set_color_depth(32);
10 set_gfx_mode(GFX_AUTODETECT_WINDOWED, 800, 600, 0, 0);
11
12 backbuffer = create_bitmap(800, 600);
13 clear_to_color(backbuffer, makecol(0,0,0));
14
15 dfile = load_datafile("running.dat");
16 if (!dfile)
17 {
18 allegro_message("Error loading datafile");
19 exit(-1);
20 }
21 for (int i= 0; dfile<i>.type != DAT_END; i++)
22 {
23 name = get_datafile_property(dfile+i, DAT_NAME);
24 allegro_message("name: %s", name);
25 }
26
27 readkey();
28 unload_datafile(dfile);
29 return 0;
30}
31END_OF_MAIN()

after I ran the programe, why did all objects's name is empty_string?

the contents of unning.dat:
<root>
[0] BMP 000_BMP
[2] BMP 001_BMP
[3] BMP 002_BMP
...
etc
int the grabber.exe , i found that every object include NAME property.
how can I get the their names in my program?
thnks a lot.

Thomas Fjellstrom

edit: nevermind. not thinking...

sj971059

I found that after i used another *dat file to test the program, the program ran normally.

The running.dat was modified by me and I imported something else into it,
maybe I had destroyed it which result in the program's abnormity.

Thread #587474. Printed from Allegro.cc