#ifdef TEST

short	myCallBack()
{
#ifdef _MACINTOSH_
	return Button();
#endif
#ifdef _WINDOWS_
   return (0);
#endif

}


void main(void)
{
	char	Choice[80];
	char	Choice2[30];
	char	Suggestion[256];
	char	Comment[256];
	void	*Speller;
	short	Result;
	long	Size;
	unsigned long	DictNum;

	WordInfo	theInfo;
	short		Auto;
	short		DictType;

	long		lastDict;
	long		lastType;
	char		lastWord[60];

#ifdef _MACINTOSH_
	StandardFileReply	reply;
	SFTypeList	types = {'mnD '};
#endif


	Speller = StartSpellCheckSession();


	for(;;)
	{
		printf("API Test\n\n");
		printf("1.  Open Dictionary\n");
		printf("2.  Close Dictionary\n");
		printf("3.  Check Word\n");
		printf("4.  Get First Suggestion\n");
		printf("5.  Get Next Suggestion\n");
		printf("6.  Find First Regular Expression\n");
		printf("7.  Find Next Regular Expression\n");
		printf("8.  Find Word\n");
		printf("9.  Find Next Word\n");
		printf("10. Current Word\n");
		printf("11. Add Word\n");
		printf("12. Fix Case\n");
		printf("0.  Quit\n");
		printf("\nSelection: ");

		gets(Choice);
		Result = atoi(Choice);
		printf("\n\n");

		switch(Result)
		{
			case 1:
#ifdef _MACINTOSH_
				StandardGetFile(nil, 1, types, &reply);
#endif
#ifdef _WINDOWS_
				printf("\nName of the Dictionary File:");
				gets(Choice);
#endif

				printf("\nSize: ");
				gets(Choice2);
				Size = atoi(Choice2);

				printf("AUTO_DICT             (1)");
				printf("\n SUGGEST_DICT       (2)");
				printf("\n DOCUMENT_DICT      (4)");
				printf("\n SKIP_DICT          (8)");
				printf("\n USER_DICT          (16)");
				printf("\n MAIN_DICT          (32)");

				printf("\nDictionary Type Number: ");
				gets(Choice2);
				DictType = atoi(Choice2);

				if (Size == 0)
				{	Size = 15;
					printf("\n 15 Buffers by default");
				}


					#ifdef _MACINTOSH_
				if (!reply.sfGood)
					if (DictOpen(Speller, &DictNum, DictType, Size, nil) != 0)
					#endif
					#ifdef _WINDOWS_ | _MSDOS_
				if(1)
					if (DictOpen(Speller, &DictNum, DictType, Size, Choice) != 0)
					#endif
					{
						printf("\nThe dictionary number is: %ld\n",DictNum);
					} else
					{	printf("Unable to open dictionary\n");
					}
				#ifdef _MACINTOSH_
				else
					if (DictOpen(Speller, &DictNum, DictType, Size, &reply.sfFile))
					{
						printf("\nThe dictionary number is: %ld\n",DictNum);
					} else
					{	printf("Unable to open dictionary\n");
					}
				#endif
				break;

			case 2:
				printf("Dictionary Number to Close: ");
				gets(Choice);
				DictNum = atoi(Choice);
				DictClose(Speller, DictNum);
				break;

			case 3: 
				printf("Word to Check: ");
				gets(lastWord);
				printf("Dictionaries to check: ");
				gets(Choice2);
				lastDict = atoi(Choice2);
				printf("Type to check (return for all): ");
				gets(Choice2);
				lastType = atoi(Choice2);

				Size = CheckWord(Speller, lastDict, lastType, lastWord, &theInfo);
				if (Size)
				{	printf("\nFOUND: %s\n", lastWord);
					printf("Case: %d\n", theInfo.Case);
					printf("Duplicate: %d\n", theInfo.Duplicate);
					printf("Replace: %d\n", theInfo.Replace);
					printf("Errors: %d\n", GetSpellError());
				} else
				{	printf("\nDIDN'T FIND: %s\n", lastWord);
					printf("Case: %d\n", theInfo.Case);
					printf("Duplicate: %d\n", theInfo.Duplicate);
					printf("Replace: %d\n", theInfo.Replace);
					printf("Errors: %d\n", GetSpellError());

				}
				break;

			case 4:

				Size = FindFirstSuggestion(Speller, lastDict, lastType, lastWord, Suggestion, Comment, &Auto, &myCallBack);
				if (Size != 0)
				{	printf("Suggestion: %s\n", Suggestion);
					printf("Comment: %s\n", Comment);
					printf("Auto: %d\n", Auto);
					printf("Errors: %d\n", GetSpellError());

				} else
				{ 	printf("No Suggestions\n");
					printf("Errors: %d\n", GetSpellError());
				}
				break;

			case 5:
				Size = FindNextSuggestion(Speller, lastDict, lastType, lastWord, Suggestion, Comment, &Auto, &myCallBack);
				if (Size)
				{	printf("Suggestion: %s\n", Suggestion);
					printf("Comment: %s\n", Comment);
					printf("Auto: %d\n", Auto);
					printf("Errors: %d\n", GetSpellError());
				} else
				{ 	printf("No Suggestions\n");
					printf("Errors: %d\n", GetSpellError());
				}
				break;

			case 6:
				printf("Expression to Search: ");
				gets(Choice);
				printf("Dictionaries to check: ");
				gets(Choice2);
				DictNum = atoi(Choice2);
				printf("Type to check (0 for just number): ");
				gets(Choice2);
				DictType = atoi(Choice2);
				Size = FindFirstRegex(Speller, DictNum, DictType, Choice, &myCallBack);
				if (Size)
				{	printf("Suggestion: %s\n", Choice);
				} else
				{ 	printf("No Suggestions\n");
				}
				break;

			case 7:
				printf("(Make sure this is the same word as used on get first suggestion)\n");
				printf("Expression to Search: ");
				gets(Choice);
				printf("Dictionaries to check: ");
				gets(Choice2);
				DictNum = atoi(Choice2);
				printf("Type to check (0 for just number): ");
				gets(Choice2);
				DictType = atoi(Choice2);
				Size = FindNextRegex(Speller, DictNum, DictType, Choice, &myCallBack);
				if (Size)
				{	printf("Suggestion: %s\n", Choice);
				} else
				{ 	printf("No Suggestions\n");
				}
				break;

			case 8:
				printf("Word to Search for: ");
				gets(Choice);
				printf("Dictionaries to check: ");
				gets(Choice2);
				DictNum = atoi(Choice2);
				printf("Type to check (0 for just number): ");
				gets(Choice2);
				DictType = atoi(Choice2);
				Size = LocateWord(Speller, DictNum, DictType, Choice);
				if (Size)
				{	printf("Suggestion: %s\n", Choice);
				} else
				{ 	printf("No Suggestions\n");
				}
				break;

			case 9:
				printf("(Make sure this is the same word as used on get first suggestion)\n");
				printf("Word to Search for: ");
				gets(Choice);
				printf("Dictionaries to check: ");
				gets(Choice2);
				DictNum = atoi(Choice2);
				printf("Type to check (0 for just number): ");
				gets(Choice2);
				DictType = atoi(Choice2);
				Size = NextWord(Speller, DictNum, DictType, Choice);
				if (Size)
				{	printf("Suggestion: %s\n", Choice);
				} else
				{ 	printf("No Suggestions\n");
				}
				break;

			case 10:
				printf("Dictionaries to check: ");
				gets(Choice2);
				DictNum = atoi(Choice2);
				printf("Type to check (0 for just number): ");
				gets(Choice2);
				DictType = atoi(Choice2);
				Size = CurrentWord(Speller, DictNum, DictType, Choice);
				if (Size)
				{	printf("Suggestion: %s\n", Choice);
				} else
				{ 	printf("No Suggestions\n");
				}
				break;
			case 11:
				printf("Dictionary to add to: ");
				gets(Choice2);
				printf("Word to add: ");
				gets(Choice);
				DictNum = atoi(Choice2);
				printf("Suggestion: ");
				gets(Suggestion);
				printf("Comment: ");
				gets(Comment);
				Size = AddToDictionary(Speller, DictNum, Choice, Suggestion, Comment);
				break;
			case 12:
				printf("Word to convert: ");
				gets(Choice);
				printf("Case code: ");
				gets(Choice2);
				DictNum = atoi(Choice2);
				FixCase(Speller, Choice, DictNum);
				printf("\nWord: %s\n", Choice);
				break;
			case 0:
				printf("\nQuiting...");
				EndSpellCheckSession(Speller);
				exit(1);
		} // switch
	} // for

// This is called in case 0:
//	EndSpellCheckSession(Speller);
}

#endif





