Exploration - output results to file

fopen write mode = "a" is used to append exploration results to a file. Often times the Exploration screen results is not the same as the file output(i.e. file output has less records). This is due to sharing violation. The AFL code below is a possible solution to this problem with Do..While loop. I have tried Exploration of 100,000 lines output and so far the file output is the same as screen results. Please help comment if this method is appropriate.

if ( Status( "stocknum" ) == 0 )
	//Open file with mode = "w" for the first time.
	fh = fopen( "c:\\output_file.csv", "w",shared=True);
else 
	//Append subsequent line to the output file.
	fh = fopen( "c:\\output_file.csv", "a",shared=True);

// Do whatever

if (fh) {
	//Do file output.
	fputs(.......);
	fclose(fh);
}
else {
    // if output collision and fh is null, do fopen until fopen success
    do 
		fh = fopen("c:\\output_file.csv", "a",shared=True);
  	while (!fh);
  	if (fh) {
	//Do file output.
	    fputs(.......);
		fclose(fh);
	}
}

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.