//	M060 : t@C̃Rs[xt@C
option double;

//------------------------------------------------------------------------------//
//	t@C̃Rs[xt@C												//
//																				//
//	߂l	F	Ȃ															//
//------------------------------------------------------------------------------//
function main()
{
	define	bno, finp, fout, fcmp, bytes, seek;
	define	$InpFile, $BinFile, $TxtFile;
	define	$txt, $cmp;
	define	fUnmatch;
	define	count;

	_Cls();

	bno = _MemAlloc(128);						//	ubN蓖

	//	t@CpXݒ
	$InpFile = $_StrCat($_MyPath, "TestData1.txt");
	$BinFile = $_StrCat($_MyPath, "BinData.txt");
	$TxtFile = $_StrCat($_MyPath, "TxtData.txt");

	_Print("oCiANZXɂt@CRs[iTestData1.txt -> BinData.txtj\n");
	count = 0;
	if ((finp = _FOpen($InpFile, "rb")) && (fout = _FOpen($BinFile, "wb"))) {
		while (bytes = _FRead(finp, bno, 0, 128)) {
			_FWrite(fout, bno, 0, bytes);
			//	̓t@CăI[vāASEEKeXg
			if (count == 5) {
				seek = _FGetSeek(finp);
				_FClose(finp);
				finp = _FOpen($InpFile, "rb");
				_FSetSeek(finp, seek);
			}
			count++;
		}
		_FClose(finp);
		_FClose(fout);
	}

	_Print("eLXgANZXɂt@CRs[iTestData1.txt -> TxtData.txtj\n");
	if ((finp = _FOpen($InpFile, "rt")) && (fout = _FOpen($TxtFile, "wt"))) {
		while ($txt = $_FGetS(finp)) {
			_FPutS(fout, $txt);
		}
		_FClose(finp);
		_FClose(fout);
	}

	_Print("t@CRyA(BinFile)\n");
	fUnmatch = _FALSE;
	if ((finp = _FOpen($InpFile, "rt")) && (fcmp = _FOpen($BinFile, "rt"))) {
		while ($txt = $_FGetS(finp)) {
			$cmp = $_FGetS(fcmp);
			if ($txt != $cmp) {
				fUnmatch = _TRUE;
				break;
			}
		}
		_FClose(finp);
		_FClose(fcmp);
	}
	_Print("TestData1.txt VS BinData.txt --> ");
	if (fUnmatch) _Print("Unmatch(NG)");
	else		  _Print("Match(OK)\n");

	_Print("t@CRyA(TxtFile)\n");
	fUnmatch = _FALSE;
	if ((finp = _FOpen($InpFile, "rt")) && (fcmp = _FOpen($TxtFile, "rt"))) {
		while ($txt = $_FGetS(finp)) {
			$cmp = $_FGetS(fcmp);
			if ($txt != $cmp) {
				fUnmatch = _TRUE;
				break;
			}
		}
		_FClose(finp);
		_FClose(fcmp);
	}
	_Print("TestData1.txt VS TxtData.txt --> ");
	if (fUnmatch) _Print("Unmatch(NG)");
	else		  _Print("Match(OK)\n");

	_Print("t@C폜(BinData.txt, TxtData.txt)\n");
	_FDelete($BinFile);
	_FDelete($TxtFile);

	_MemFree(bno);								//	ubN

}
