Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » there is something strange i can't get datafile object's name....

This thread is locked; no one can reply to it. rss feed Print
there is something strange i can't get datafile object's name....
sj971059
Member #7,689
August 2006

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
Member #476
June 2000
avatar

edit: nevermind. not thinking...

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

sj971059
Member #7,689
August 2006

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.

Go to: