macro AutoCorr;
{ Does an AutoCorrelation of the top 2D data window }
var
	boolean : hasData;
	str255 : name;
	longint : x,y;
begin
	DisposeUnClose;
	hasData:=FrontData(name,'data');
	if(!hasData) then
		ShowError('Error','There are no active data windows');
		exit;
	endif;
	x:=64;
	y:=64;
	DuplicateData(name,FALSE,'DUP');
	FFT2D('DUP','',x,y,0.000,'M1', 'P1');
	DisposeData('DUP');
	FFT2D(name,'',x,y,0.000,'M2', 'P2');
	SimpleMath('P1',+,'None','P2','TP');
	DisposeData('P1');
	DisposeData('P2');
	SimpleMath('M1',*,'None','M2','TM');
	DisposeData('M1');
	DisposeData('M2');
	name:=concat('AC ¥ ',name);
	IFFT2D('TM','TP',x,y,0.000,name, 'TOSS');
	DisposeData('TM');
	DisposeData('TP');
	DisposeData('TOSS');
	FlipFlop(name);
end;
