Click here to Skip to main content
15,905,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I had created a file called "Input.txt" which contains 2 lines as
ABC123;01/02/2008
PRQ456;04/23/2004
I had written LineParse function.
In that I am getting the first name in the line. Using that name I am searching respective documents in DB.
These documents retrived and stroed in one folder with naming convention as "<type><inc no>.PDF"
Where type is : R/X/F depending on document type.
Inc no: is the number which should increment by 1 each time I am storing document in folder.

Everything is working fine for me except "inc no".
Till now I am incrementing that number depending on responses I got.
For first "ABC123" I got 2 responses and for "PQR456" I am receiving 4 responses, so total 6 documents should be available in output folder.

sprintf(Incnumber,"%06d", iResponse + 1); // need to change the logic
sprintf(Docfile,"%s/%c%s.%s",Dir_Path,DType,Incnumber,"PDF");

But my inc no is overrided for first 2 docs, hence I am receiving only 4 docs in output folder as r000001.PDF, r000002.PDF, r000003.PDF, r000004.PDF.
As r000001.PDF and r000002.PDF is getting override each time.

Help me out.
Thanks in advance.
Posted

Without seeing additional code, my guess is that you reset your increment counter for every line you parse.

Cheers
 
Share this answer
 
You just need to maintain a cumulative counter for the responses, for instance:

C
iTotalResponses += iResponse;
sprintf(Incnumber,"%06d", iTotalResponses + 1); 
sprintf(Docfile,"%s/%c%s %s",Dir_Path,DType,Incnumber,"PDF");


:)
 
Share this answer
 
Thanks for reply.

I had called a ExtractDoc() function with iResponse.
So for first line parse i get iResponse = 0 and then iResponse =1.
For second line parse i get iResponse=0 then =1 then =2 then =4 etc....

So whenever I increment Incnumber,
sprintf(Incnumber,"%06d", iResponse + 1);
for iResponse 0 and 1 , document name gets override.

Thanks in advance
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900