benchmark BenchmarkName use "kernel.bdh" dcluser user user1 transactions tMain : 1; dcltrans transaction TMain var hFile1, HFile2 : number; //variables to be used nread : number; sData : string; nSize, nHalfSize : number; begin //pass a handle to file to read from FOpen(hFile1, "MyText.txt", OPT_FILE_ACCESS_READWRITE, OPT_FILE_OPEN); //create new file and pass handle to it - this is where data will eventually be written to //this file will be created in your project directory FOpen(hFile2, "MyText2.txt", OPT_FILE_ACCESS_READWRITE, OPT_FILE_CREATE); FSizeGet(hFile1, nSize); //get size of File we are reading from nHalfSize := nSize/2; //make nHalfSize = 50% of the file size //current pointer position FCurrentPositionSet(hFile1, 0, OPT_FILE_CURRENT); // reads nBytes from file and writes into sData FRead(hFile1, sData, nHalfSize); //writes 50% Data to new file FWrite(hFile2, sData,nHalfSize, OPT_FILE_INSERT); //passes a handle to current position FCurrentPositionSet(hFile1, 0, OPT_FILE_CURRENT); //reads 50% of nBytes from file and writes to sData FRead(hFile1, sData,nHalfSize); // passes handle to current file position FCurrentPositionSet(hFile2, 0, OPT_FILE_CURRENT); //writes other 50% of data to file fWrite(hFile2, sData, nHalfSize, OPT_FILE_APPEND); // close file handles FClose(hFile1); FClose(hFile2); end TMain;
↧