macro Open_IPLab;
var
	boolean : good,isByte,isInteger,isLong,isReal,old;
	integer : refNum, fileType,version;
	longint : width, height, offset;
	str255 : fName, dataStr,s;
begin
	showinfo('',' ',' ',' ');
	good:=GetFile('Select an IPLab File...',fName,'IPLI');
	if (good) then
		OpenFile(fName,refNum);
		OffsetFile(refNum,TRUE,0);
		ReadFile(refNum,version,1);
		old:=Cmp(version,=,12544);
		if(old) 
			offset:=2102;
		elseif
			offset:=2120;
		endif;
		OffsetFile(refNum,TRUE,4);
		ReadFile(refNum,fileType);
		OffsetFile(refNum,TRUE,6);
		ReadFile(refNum,width);
		OffsetFile(refNum,TRUE,10);
		ReadFile(refNum,height);
		CloseFile(refNum);
		s:=concat(fileType:1,'  ',width:1,'  ',height:1);
		ShowInfo('',s,s,s);
		isByte:=Cmp(fileType,=,0);
		isInteger:=Cmp(fileType,=,1);
		isLong:=Cmp(fileType,=,2);
		isReal:=Cmp(fileType,=,3);
		if (isByte) then
			dataStr:='ByteNum';
		elseif
			if (isInteger) then
				dataStr:='Integer';
			elseif
				if (isLong) then
					dataStr:='Longint';
				elseif
					if (isReal) then
						dataStr:='Real';
					endif;
				endif;
			endif;
		endif;
		ReadBinaryOptions(width,height,offset,dataStr,FALSE);
		OpenData(fName,'Binary',FALSE);
	endif;
end;
