The Recursive Print Loop

For a complete print loop which is supporting sequence tables und sub-tables, there is nothing more to do. The code from the last two sections makes sure that the complete tree of the table structure is printed.

So only the finishing touches have to be added – e.g. to display a progress bar. The structure of a layout can be quite complex. Thus it is not possible to just take the current position inside the data source as percentage. This approach does not work as soon as the user puts two tables in series. Therefore List & Label allows you to get the count of tables at the root level (LlPrintDbGetRootTableCount()). Whenever you display a data record from the root level, you can update the progress bar.

The following holds for the maximum available percentage of a table:

INT nMaxPerc = 100/LlPrintDbGetRootTableCount();

If you index the root tables from 0.. LlPrintDbGetRootTableCount()-1, you can calculate the total percentage as

INT nPercTotal = nMaxPerc*nIndexCurrentTable+(nPerc/100*nMaxPerc);

where nPerc is the percentage position in the current table. To properly update the progress bar, you can adapt the function PrintTable() from the last section. The current depth of the recursion can be determined with another input parameter – if this parameter is 0, a "root" data record is printed and the progress bar can be updated:

function PrintTable(DataTable data object, depth of recursion depth)
{
       <repeat>
       {
               <define fields of DataTable>
               ...
               <if depth==0 update progress bar>
                       (LlPrintDbGetRootTableCount,
                        LlPrintSetBoxText)
               <print row>
                        (LlPrintFields)
               <as long as warning repeat >
                       (LlPrint,
                        Ret = LlPrintFields)
               <repeat until Ret <> LL_WRN_TABLECHANGE >
               {
                      ...
                      <generate an appropriate DataTable child object>
                      <Ret = PrintTable(child DataTable, depth+1)>
               }
               ...
       }
}