From: G DOT DegliEsposti AT ads DOT it To: fjgpp AT delorie DOT com Message-ID: Date: Thu, 29 Jan 1998 09:46:45 +0100 Subject: Re: Allegro Datafiles - More Problems Mime-Version: 1.0 Content-type: text/plain; charset=us-ascii Precedence: bulk >Leave it to me to run into more problems :) 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". I >get this error when compiling: > >Error: array subscript is not an integer of course: you are trying to do this illegal operation: draw_sprite(screen,datafile["BLANK"].dat,16,16); I suppose this is what you really want to do: draw_sprite(screen,datafile[BLANK].dat,16,16); where BLANK is #define'd somewhere... the 'spritename' must be an int containing BLANK. If you need to use different values assign different ints to spritename. >Second problem: having 2 datafiles opened at the same time. Having a >datafile already opened seems to cause the second one to return 1. My >two DATAFILE declarations are different. My code to open the second >datafile is below: > >{ > strcpy(get_filename(buf), "c:/maped/testspr.dat"); > user_datafile = load_datafile(buf); > if (!user_datafile) { > allegro_exit(); > printf("Error loading TESTSPR.DAT!\n\n"); > return 1; > } >} > >I *believe* that the problem is due to there already being a datafile >open, but am not positive. The datafile is not corrupt, and it's header >is correct and in-place. I agree with you. ciao Giacomo