Mail Archives: djgpp/1997/04/01/18:12:12
Kenton E. Sinner writes:
>Could someone please post or email me a sample of code for using the
>file_select function in an actual program? I've tried, but my programs
>keep spontaneously exiting and trying to land in drive A: of all places.
Look in allegro/tools/grabber.c. For example, there is a function:
/* handle the load command */
int loader()
{
char buf[256];
strcpy(buf, data_file);
*get_filename(buf) = 0;
if (file_select("Load data file", buf, "DAT")) {
strlwr(buf);
load(buf);
}
return D_REDRAW;
}
That should be fairly easy to follow. It copies the current filename
(data_file) into a temporary string, strips off the filename and
extension to leave just the path, displays the file selector, and then
calls the load() routine if the user clicked on OK.
--
Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/
Beauty is a French phonetic corruption of a short cloth neck ornament.
- Raw text -