Quantcast
Channel: Silk Performer
Viewing all articles
Browse latest Browse all 4084

Wiki Page: Is it possible to read the contents of a file in segments and then write this to a different location?

$
0
0
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;

Viewing all articles
Browse latest Browse all 4084

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>