%{----------------------------------------------------------------------------%} %{ StartRow.ndm -- Net.Data table processing with Starting Row number %} %{ Create numbered links to show sections of a resultset. %} %{ %} %{ Copyright (c) 2000, Craig Pelkie %} %{ ALL RIGHTS RESERVED %} %{----------------------------------------------------------------------------%} %{----------------------------------------------------------------------------%} %{ Section A - Define section for the macro %} %{----------------------------------------------------------------------------%} %define { DATABASE = "*LOCAL" DTW_DEFAULT_REPORT = "NO" DTW_SET_TOTAL_ROWS = "YES" RPT_MAX_ROWS = "10" currentPage = "0" pageCount = "1" rowCount = "0" rowIndex = "1" rowIndexNext = "1" totalPages = "0" %} %{----------------------------------------------------------------------------%} %{ Section B - RUNSQL - run the SQL statement, generate HTML table %} %{----------------------------------------------------------------------------%} %function(DTW_SQL) RUNSQL() { select * from apilib.parts order by partno %report{ %{--------------------------------------------------------------------%} %{ Section C - test for empty result set, exit if empty %} %{--------------------------------------------------------------------%} %if (TOTAL_ROWS == "0") No rows retrieved for query. @dtw_exit() %endif
| %{---------------------------------------------------------%} %{ Section D - calculate/display total number of pages to %} %{ generate (whole and fractional) %} %{---------------------------------------------------------%} @dtw_assign(totalPages, @dtw_rintdiv(TOTAL_ROWS, RPT_MAX_ROWS)) %if (@dtw_rdivrem(TOTAL_ROWS, RPT_MAX_ROWS) > "0") @dtw_add(totalPages, "1", totalPages) %endif Total rows: $(TOTAL_ROWS) Total pages: $(totalPages) %{---------------------------------------------------------%} %{ Section E - Put "<< Prev"" option if on page 2..n %} %{---------------------------------------------------------%} %if (START_ROW_NUM > RPT_MAX_ROWS) << Prev %endif %{---------------------------------------------------------%} %{ Section F - Put links for each page %} %{---------------------------------------------------------%} %while(pageCount <= totalPages) { %{-----------------------------------------------------%} %{ Section G - link for "current page" %} %{-----------------------------------------------------%} %if (rowIndex == START_ROW_NUM) $(pageCount) @dtw_assign(rowIndexNext, @dtw_radd(rowIndex, RPT_MAX_ROWS)) @dtw_assign(currentPage, pageCount) %{-----------------------------------------------------%} %{ Section H - link for other pages %} %{-----------------------------------------------------%} %else $(pageCount) %endif @dtw_add(rowIndex, RPT_MAX_ROWS, rowIndex) @dtw_add(pageCount, "1", pageCount) %} %{---------------------------------------------------------%} %{ Section I - Put "Next >>" option if on page 1..n-1 %} %{---------------------------------------------------------%} %if (currentPage < totalPages) Next >> %endif | ||||
| $(N1) | $(N2) | $(N3) | $(N4) | $(N5) |
|---|---|---|---|---|
| $(V1) | $(V2) | $(V3) | $(V4) | $(V5) |