/*
 *  kd_freq.library NewFR() Test
 *
 *  This demonstrates the use of CreateFRequest(), DeleteFRequest() and
 *  NewFReq() for a minimum of fuss in allocating stuff for the FR.
 *
 *  Note the use of  NextSelectEntry() to check the select list.
 *
 *  You need to assemble and link  glue.asm with this, or use the
 *  appropriate #pragmas!
 *
 */


#include "KDBase.h"

struct Library *KD_FReqBase, *OpenLibrary();

main()
{
struct FRequest *fr, *CreateFRequest();
char *file, *NewFReq();
UBYTE *entry, *NextSelectEntry();

if (KD_FReqBase = OpenLibrary(KLIBNAME,KLIBVERSION))
	{
	if (fr = (struct FRequest *) CreateFRequest())
		{
		/* Set the requester title */
		fr->reqtitle = (UBYTE *) "FR Test";

		/* already set by CreateFRequest() */
		fr->flags = FR_STDFLAGS | FR_SELECTLIST;

		/* Set the default show and hide wildcards */
		/*	strcpy(fr->pattern,"#?.?"); */
		/*	strcpy(fr->extras->Hide,"#?.o"); */


		/* Call the file requester and get a file name */

		if (file = (char *)NewFReq(fr))	
			printf("Selected: %s\n\n",file);
		else
			printf("Cancelled.\n\n");
		
		/* Show some of the stuff we got back from the call */

		printf("Path    : %s\n",fr->fullname);
		printf("Title   : %s\n",fr->reqtitle);
		printf("Dir     : %s\n",fr->directory);
		printf("File    : %s\n",fr->filename);
		printf("Show Pat: %s\n",fr->pattern);
		printf("Hide Pat: %s\n",fr->extras->Hide);
		printf("Position: %3d , %3d\n",fr->extras->LeftEdge,fr->extras->TopEdge);
		printf("Size    : %3d x %3d\n",fr->extras->Width,fr->extras->Height);


		/* Check if the user selected multiple files */
		
		if (fr->extras->SelectList)	
			{
			/* ok.. print them out */
			printf("\nSelect List:\n\n");

			while (entry = NextSelectEntry(fr))
				{
				printf("%s\n",entry);
				}
			}


		/* Don't do this unless you're done with the FRequest struct */

		DeleteFRequest(fr);
		}

	CloseLibrary(KD_FReqBase);
	}
else
	{
	printf("Can't Open 'kd_freq.library'.  Make sure it is in LIBS:\n");
	}
}
