%{*********************************************************%} %{ svg_ndm.ndm Generate SVG using Net.Data %} %{ %} %{ Craig Pelkie %} %{ Bits & Bytes Programming, Inc. %} %{ craig@web400.com %} %{ Copyright (c) 2001, Craig Pelkie %} %{ ALL RIGHTS RESERVED %} %{*********************************************************%} %{*********************************************************%} %{ A: Defines for macro %} %{*********************************************************%} %define { DATABASE = "*LOCAL" DTW_DEFAULT_REPORT = "NO" DTW_PRINT_HEADER = "NO" DTW_REMOVE_WS = "NO" tblBaldue = %table %} %{*********************************************************%} %{ B: Get balance due table %} %{*********************************************************%} %function(DTW_SQL) GetBaldue(out tblBaldue) { select * from qiws.qcustcdt where (baldue > 0) and (baldue < 1000.00) order by baldue desc %} %{*********************************************************%} %{ C: Make XML to display the SVG bar graph %} %{*********************************************************%} %macro_function MakeXML (in tblBaldue) { @dtw_tb_rows(tblBaldue, numRows) %{*****************************************************%} %{ D: work variables %} %{ r - row counter %} %{ y - y-axis position %} %{ total - total balance due %} %{*****************************************************%} @dtw_assign(r, "1") @dtw_assign(y, "90") @dtw_assign(total, "0") %{*****************************************************%} %{ E: colors for bar graphs %} %{ colors - array of colors (see Total balance due: @dtw_rconcat("$", total) %{*****************************************************%} %{ G: Format/display bar, info box for each customer %} %{*****************************************************%} @dtw_assign(r, "1") %while (r <= numRows) { %{*************************************************%} %{ H: Initialize y-axis values: %} %{ yts - y-axis for text (name) shadow %} %{ yrs - y-axis for rectangle (bar) shadow %} %{ yr - y-axis for rectangle (bar) %} %{*************************************************%} @dtw_add(y, "1", yts) @dtw_subtract(y, "9", yrs) @dtw_subtract(y, "10", yr) %{*************************************************%} %{ I: Extract values from row to simple variables %} %{*************************************************%} @dtw_assign(cusnum, @dtw_tb_rgetv(tblBaldue, r, "1")) @dtw_assign(lstnam, @dtw_tb_rgetv(tblBaldue, r, "2")) @dtw_assign(init, @dtw_tb_rgetv(tblBaldue, r, "3")) @dtw_assign(street, @dtw_tb_rgetv(tblBaldue, r, "4")) @dtw_assign(city, @dtw_tb_rgetv(tblBaldue, r, "5")) @dtw_assign(state, @dtw_tb_rgetv(tblBaldue, r, "6")) @dtw_assign(zipcod, @dtw_tb_rgetv(tblBaldue, r, "7")) @dtw_assign(cdtlmt, @dtw_tb_rgetv(tblBaldue, r, "8")) @dtw_assign(chgcod, @dtw_tb_rgetv(tblBaldue, r, "9")) @dtw_assign(baldue, @dtw_tb_rgetv(tblBaldue, r, "10")) @dtw_assign(cdtdue, @dtw_tb_rgetv(tblBaldue, r, "11")) %{*************************************************%} %{ J: Make customer name as INIT LSTNAM %} %{*************************************************%} @dtw_assign(name, init) @dtw_assign(name, @dtw_rconcat(name, " ")) @dtw_assign(name, @dtw_rconcat(name, lstnam)) %{*************************************************%} %{ K: Set width of bar to display percentage of %} %{ total balance due. %} %{ Bar graphs are displayed as their percentage of %} %{ a maximum width of 300. To better show scale, %} %{ the calculated percentage is multipled by 2. %} %{*************************************************%} @dtw_divide(baldue, total, "4", percent) @dtw_multiply(percent, "300", width) @dtw_multiply(width, "2", width) @dtw_multiply(percent, "100", "4", percent) %{*************************************************%} %{ L: Extract color value from colors array. %} %{*************************************************%} @dtw_substr(colors, colorN, "1", color) @dtw_add(colorN, "1", colorN) %if (colorN > colorMax) { @dtw_assign(colorN, "1") %endif %{*************************************************%} %{ M: Output SVG tags for customer. %} %{*************************************************%} /***************************************************/ /* $(name) */ /***************************************************/ $(name) $(name) @dtw_rconcat("$", baldue) $(percent)% $(street) $(city), $(state) $(zipcod) @dtw_rtime() @dtw_add(r, "1", r) @dtw_add(y, "20", y) %} %} %{*********************************************************%} %{ N: %html input block - macro starts executing here %} %{*********************************************************%} %html(input) { Content-Type: image/svg-xml Content-encoding: ebcdic ]> /***************************************************************/ /* R: SVG for customer detail bounding rectangle */ /***************************************************************/ @GetBaldue(tblBaldue) @MakeXML(tblBaldue) %}