From: Shawn Hargreaves Newsgroups: comp.os.msdos.djgpp Subject: Re: Allegro Datafiles - More Problems Date: Thu, 29 Jan 1998 19:28:48 +0000 Organization: None Distribution: world Message-ID: References: NNTP-Posting-Host: talula.demon.co.uk MIME-Version: 1.0 Lines: 37 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Matt Riker writes: >First problem, is when I try and substitute a datafile object with a >variable. Example: > > draw_sprite(screen,datafile[spritename].dat,16,16); > >spritename is a char with a 20 character array, containing "BLANK". An array index must always be an integer value, just like the compiler error message is telling you. Change your spritename variable to an int, and initialise it with the numeric value BLANK (which is a #defined constant from the grabber header file), rather than the string "BLANK". It sounds to me like you need to dig out a good C book and do some reading about the differences between integers, arrays, and string data! >Second problem: having 2 datafiles opened at the same time. [...] > strcpy(get_filename(buf), "c:/maped/testspr.dat"); > user_datafile = load_datafile(buf); Why make life so complicated for yourself? Since you are using a fully-qualified path, just pass "c:/maped/testspr.dat" directly to the load_datafile() call. That more complex code, which I presume you copied from one of the Allegro utilities, is intended to handle files from different directories, and won't work if you are directly supplying a full path to the file. Assuming you have initialised the buffer to an empty string, the first time you run this code it will just be changed to the name of your file, but on a subsequent execution the filename of the original path will be replaced by the new string, giving something like "c:/maped/c:/maped/testspr.dat", which is not at all what you want... -- Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/ "Pigs use it for a tambourine" - Frank Zappa