FileAppend1(FileName1,count1); FileClose(handle1); FileAppend2(FileName2,count2); FileClose(handle2);You are opening the file multiple times and loosing the earlier handles. Thus you open 10 and close 1 leaving 9 open.
while(counter < 10) { handle1 = FileOpen(FileName1,FILE_CSV|FILE_READ|FILE_WRITE); if(handle1 == -1)..
Open the file once BEFORE the while, put the close AFTER the while, not in the caller.
Why are you writing the same values 10 times to the file?
He is trying:
You are opening the file multiple times and loosing the earlier handles. Thus you open 10 and close 1 leaving 9 open.
Open the file once BEFORE the while, put the close AFTER the while, not in the caller.
Why are you writing the same values 10 times to the file?
WHRoeder,
Thank you for your reply. This is just a prototype for the final code I am building. I am having problems writing large text files. When my record count approaches a certain amount (ie. 27,000,000 Records), for some reason, the file gets overwritten. Initially I thought that the internal counter in my code was maxing out for the variable that I was using. This is not so as I built another program and had no problem generating many more records in a continuous file. As a result, I am have to build multiple text files to get the complete population of records I want.
I made the change but continue to receive error messages after the program reaches record #41. After this I get the error messages:
FileOpen - too many opened files
EURUSD, M1: File Print Failed
Don't do this .. . .
handle1 = FileOpen(FileName1,FILE_CSV|FILE_READ|FILE_WRITE); while(counter < 10) { handle1 = FileOpen(FileName1,FILE_CSV|FILE_READ|FILE_WRITE); if(handle1 == -1) {
do this . . .
handle1 = FileOpen(FileName1,FILE_CSV|FILE_READ|FILE_WRITE); while(counter < 10) { // <--- line deleted if(handle1 == -1) {
RaptorUK,
Thank you for your response. Dumb misstake on my part. I am getting lazy and am going to have to take more time in reviewing my code.
Everything is working great now.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Can someone help me with the included code? I am having problems with closing the first file and going onto the next file. What is occuring is that the initial file remains open. How do I close the first file when going onto the second file.