#import <remote/NXConnection.h>
/*
	This is the nastiest program I've done so far.  In fifteen minutes it changed 800+ SmartFields in 33 nibs into TextFields and SmartCells into TextCells.  If you have ever seriously used SmartFields then you probably know why I wanted to do that.
*/

main()
{
	id server;
	id docList;
	int count;
	id 
		obj,
		cell,
		parser;
	char
		buf[256]="";
	server = [NXConnection connectToName:"IBMole"];
	if (server)
	{
		printf("Got the mole!\n");
	}
	docList = [server docList];
	count = [docList count];
	printf("%d docs\n",count);
	while (count--)
	{
		int objCount;
		id objs=[[List alloc] init];
		
		[[docList objectAt:count] getObjects:objs];
		objCount = [objs count];
	printf("%d objects\n",objCount);
		while (objCount--)
		{
			cell = nil;
			obj = [objs objectAt:objCount];
			printf("%s class\n",[[obj class] name]);
			if ([obj respondsTo:@selector(setTextDelegate:)])
			{
				[obj setTextDelegate:NULL];
				printf("Changed textDelegate\n");
			}
			if (!strcmp("OTSmartField",[[obj class] name]))
			{
				cell = [obj cell];
			}
			
			if (!strcmp("OTSmartCell",[[obj class] name]))
			{
				cell = obj;
			}
			printf("cell is %s\n",[[cell class] name]);
			printf("parser is %s\n",[[[cell parser] class] name]);
			if (cell)
			{
				parser = [cell parser];
				if (!strcmp("OTPvdLookup",[[parser class] name]))
				{
					if ([obj isEditable] && strcmp("date",[parser lookupName]))
					{//becomeSuperclass method installed as a catagory to Object in my palette...
						[obj becomeSuperclass];
						[cell becomeSuperclass];
						printf("Turned a SmartField to a TextField!\n");
					}
					printf(".\n");
				}
			}

		}
	}
	exit(0);
}
