program Compare;

uses
			global,
			indexes,
			files,
			minilib,
			kdirctry, kperson, kmemship;

var
	OldJimmy : PDataStream;
	Rec, ID, NumRecs : longint;
	Member, OldMember : PDirectoryItem;
	IndexItem, OldIndexItem : PIndexItem;
	NumDeleted, NumAdded, NumChanged : word;

begin
	FileAdmin[fiJimmys]^.LogOn;
	FIleAdmin[fiFullDirIdx]^.LogOn;

	New(OldJimmy, init('c:\kameleon\old\JIMMYS.DAT', 1));

	NumDeleted := 0;
	NumAdded := 0;
	NumChanged := 0;

	ID := 0; NumRecs := Stream(fiJimmys)^.NoRecs;

	while ID<NumRecs do begin

		Member := PDirectoryItem(Stream(fiJimmys)^.GetAt(ID));

		if Member<>nil then begin
			if typeof(Member^)=typeof(TMember) then begin

				if ID>OldJimmy^.NoRecs then
					inc(NumAdded)
				else begin

					OldMember := PDirectoryItem(OldJimmy^.GetAt(ID));

					if OldMember<>nil then begin
						if (Member^.Deleted<>Oldmember^.Deleted) then
							inc(NumDeleted)
						else
							{changed?}
							if Member^.GetKeyString(1,1)<>OldMember^.GetKeyString(1,1) then
								inc(NumChanged)
							else
								if delspace(Member^.GetAddress(2))<>delspace(OldMember^.GetAddress(2)) then
									inc(NumChanged);

						dispose(OldMember, done);
					end;
				end;
			end;

			if typeof(Member^)=typeof(TMember) then ID := ID + TMemberSize-1;

			writeln(ID,'/',NumRecs,': Del=',NumDeleted,', Changed=',NumChanged,', New=',NumAdded);

			dispose(Member, done);
		end else begin
			if Stream(fiJimmys)^.ErrorInfo=1105 then ID := ID + 99; {old membership status object}
			Stream(fiJimmys)^.Reset;
		end;

		inc(ID);

	end;

	dispose(OldJimmy, done);

	FileAdmin[fiJimmys]^.LogOff;
	FileAdmin[fiFullDirIdx]^.LogOff;

end.

