Dear Expert
I failed to get the row number. Can you please correct the above logic for both .txt file and for row number. I tried alot but gave me a common number for the row number (i-e 1)
Thank You
Generate Report
-
- Posts: 160
- Joined: November 21st, 2022, 4:41 pm
Re: Generate Report
This is how I coded the change. See how there is first a For loop to fill the lists, then a Do loop to write from the lists after. The row number is just the printed count of the Do loop. Since we only want to open or close the report and write the top row once, the open, close, and top row writing are all outside of any loops.
Justin
function viewrepo()
string datafile = "../DATA/" + maketext("%v_%2s_%v.csdb" ,strip(loadsetting("intname")),loadsetting("intcode"), strip(getdeviceid()));
string reportfile = "../DATA/"+maketext("%v-Report.txt" , sysdate("ddmmyyyy"));
file repor;
setfile(repor , reportfile , create);
setfile(INTERVIEW_DICT, datafile);
list string enteredkey;
keylist(INTERVIEW_DICT, enteredkey);
list dateList;
list statecode;
list string typeList;
list visitlist;
list string distlist;
list string psulist;
forcase INTERVIEW_DICT do
dateList.add(DOV);
statecode.add(S_CODE);
typeList.add(getvaluelabel(MENU));
visitlist.add(V_NO);
distlist.add(D_NAME);
psulist.add(PSU_NAME);
enddo;
open(repor);
repor.write(maketext(" Date Visit District PSU Name Visit No Row Number"));
do numeric a = 1 while a <= dateList.length()
numeric tableDate = dateList(a);
string tableType = typeList(a);
numeric tablevisit = visitlist(a);
string tabledist = distlist(a);
string tablepsu = psulist(a);
repor.write(maketext("%d %v %v %2s %v %v", tableDate, tableType, tabledist, strip(tablepsu), tablevisit, a));
enddo;
close(repor);
view(filename(repor));
end;
Hope this helps,string datafile = "../DATA/" + maketext("%v_%2s_%v.csdb" ,strip(loadsetting("intname")),loadsetting("intcode"), strip(getdeviceid()));
string reportfile = "../DATA/"+maketext("%v-Report.txt" , sysdate("ddmmyyyy"));
file repor;
setfile(repor , reportfile , create);
setfile(INTERVIEW_DICT, datafile);
list string enteredkey;
keylist(INTERVIEW_DICT, enteredkey);
list dateList;
list statecode;
list string typeList;
list visitlist;
list string distlist;
list string psulist;
forcase INTERVIEW_DICT do
dateList.add(DOV);
statecode.add(S_CODE);
typeList.add(getvaluelabel(MENU));
visitlist.add(V_NO);
distlist.add(D_NAME);
psulist.add(PSU_NAME);
enddo;
open(repor);
repor.write(maketext(" Date Visit District PSU Name Visit No Row Number"));
do numeric a = 1 while a <= dateList.length()
numeric tableDate = dateList(a);
string tableType = typeList(a);
numeric tablevisit = visitlist(a);
string tabledist = distlist(a);
string tablepsu = psulist(a);
repor.write(maketext("%d %v %v %2s %v %v", tableDate, tableType, tabledist, strip(tablepsu), tablevisit, a));
enddo;
close(repor);
view(filename(repor));
end;
Justin
Re: Generate Report
Thank you sir..it's giving the desired output...
Just for the knowledge... Please suggest the codes that will give the Row number in html
Thank You
Just for the knowledge... Please suggest the codes that will give the Row number in html
Thank You
-
- Posts: 160
- Joined: November 21st, 2022, 4:41 pm
Re: Generate Report
As I'd mentioned previously, since the writing of rows here is in a nested loop, row number is not equivalent to the loop counter "b". b will reset back to 1 when there is a new Date loop, while the number of rows does not reset. Instead rowNumber is established outside of the loops and increments when a row is written, so it keeps track of how many rows there are.
Hope this helps,
Justin
Code: Select all
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>Date</th>
<th>Type of Interview</th>
<th>Number of Interviews</th>
<th>Row Number</th>
</tr>
</thead>
<?
//(list of dates, dateList, and list of types, typeList)
//(included interview database INTERVIEW with fields intvw_date and intvw_type)
numeric rowNumber = 0; //establish row number
do numeric a = 1 while a <= dateList.length()
numeric tableDate = dateList(a);
do numeric b=1 while b <= typeList.length()
rowNumber = rowNumber + 1; //increment row number
numeric tableType = dateList(b);
numeric dateRoleCount = COUNT(INTERVIEW where intvw_date=tableDate and intvw_type=tableType);
$.write("<tr>");
$.write(maketext("<td>%d - </td>", tableDate);
$.write(maketext("<td>%d - </td>", tableType);
$.write(maketext("<td>%d</td>", dateRoleCount);
$.write(maketext("<td>%d</td>", rowNumber); //print row number
$.write("</tr>");
enddo;
enddo;
?>
</table>
Justin
Re: Generate Report
Thank you so much...For the help...