/* FileRequest Demo/Test Program
 * (c) 1986 AMWare Development
 * Placed in the public domain
 * 
 * Prints the path of the selected string.  "Cancelled!" if no file
 * selected or cancel is selected.
 */


#include <exec/types.h>
#include <intuition/intuition.h>

/* must include this if want to send pointer(s) */
#include "FileRequest.h"


/* Global Variables */
struct IntuitionBase	*IntuitionBase;
struct GfxBase		*GfxBase;

/* Forward References */
UBYTE	*FileRequest();
VOID	close_up();


/* data for a wait state pointer (bubble with 2 z's) */

USHORT GPtr_dat[]=  {
	0x0000,  0x0000,
	0x0000,  0x01e0,
	0x00c0,  0x07f8,
	0x03f0,  0x0ffc,
	0x07f8,  0x1ffc,
	0x0ff8,  0x3ffe,
	0x187c,  0x3ffe,
	0x1efc,  0x7fff,
	0x3dfc,  0x7fff,
	0x387e,  0x7fff,
	0x3ffe,  0x7fff,
	0x1f0e,  0x7fff,
	0x1fdc,  0x3fff,
	0x0fbc,  0x3ffe,
	0x0f0c,  0x1ffe,
	0x07f8,  0x1ffe,
	0x01f8,  0x0ffc,
	0x01f0,  0x03fc,
	0x00c0,  0x03f8,
	0x0000,  0x01e0,
	0x0080,  0x03c0,
	0x0180,  0x03c0,
	0x0000,  0x03f0,
	0x0060,  0x00f0,
	0x0040,  0x00f0,
	0x0000,  0x00e0,
	0x0000,  0x0000
     };


/* must set up FRPointer structure if want to send a pointer */

struct FRPointer wait = { GPtr_dat, 25, 16, -7, -1 };


void main()
{
	UBYTE	*string;

	if ((IntuitionBase = (struct IntuitionBase *)
		OpenLibrary("intuition.library", 0)) == NULL) {
		puts("No intuition library!");
		close_up();
	}
	if ((GfxBase = (struct GfxBase *)
		OpenLibrary("graphics.library", 0)) == NULL) {
		puts("No graphics library!");
		close_up();
	}
	string = FileRequest(NULL, "File Requester Demo", 160, 12, NULL,
			NULL, "Demo!", NULL, NULL, &wait);

	if (string)
		puts(string);
	else
		puts("Cancelled!");

	close_up();
}


VOID close_up()
{
	if (IntuitionBase)	CloseLibrary( (VOID *)IntuitionBase);
	if (GfxBase)		CloseLibrary( (VOID *)GfxBase);

	exit(TRUE);
}
