Function affecting whole case

Discussions about CSEntry
Post Reply
htuser
Posts: 687
Joined: December 19th, 2011, 6:26 pm
Location: Silver Spring Area, MD, USA

Function affecting whole case

Post by htuser »

Dear Cspro Developer team (Gregory And Josh),
I would like to know if it's possible to write a function able to read whole questionnaires on Csentry and output several files (one file by questionnaire). By example, if i write a user defined function to output a report from a case(questionnaire) to txt, html or pdf (Thanks to Josh), i would like that the same function read and output whole cases (questionnaires) from a data entry session (data file) using a userbar.

Thanks in advance for responses.
G.VOLNY, a CSProuser from Haiti, since 2004
josh
Posts: 2403
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Function affecting whole case

Post by josh »

If i understand what you correctly you want to use a CSEntry application to read each case from a data file and for each case write out and file (using filewrite).

This is certainly possible. You would need to use an external dictionary to read your data file case by case. Then you can iterate through all the cases in that dictionary using locate and loadcase as follows:
// Start at first case in the data file
locate(MYEXTERNALDICT_DICT, >=, "");
    
// Loop through all cases
// until loadcase returns zero when it hits end of file.
while loadcase(MYEXTERNALDICT_DICT) <> 0 do

   
// write out a file for this case
   string outputFilename = pathname(Application) + "output" + maketext("-%d-%d-%d", PROVINCE, DISTRICT, HOUSEHOLD_NUMBER) + ".txt";
   
setfile(tempFile, outputFilename);
   
filewrite(tempFile, "Some stuff for this household");
   
close(tempFile);
enddo;
htuser
Posts: 687
Joined: December 19th, 2011, 6:26 pm
Location: Silver Spring Area, MD, USA

Re: Function affecting whole case

Post by htuser »

Solved! A Gold Medal to you!
This allow me to output thousands electronic forms for quality control, archiving in seconds rather than days!
Thanks a lot!
G.VOLNY, a CSProuser from Haiti, since 2004
Post Reply