home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD1.iso / Database / FDATA3-1.DMS / in.adf / FDMacros / CalcReportWidth < prev    next >
Encoding:
Text File  |  1995-09-22  |  3.5 KB  |  102 lines

  1. /* ----------------------------------------------------- */
  2. /* Final Data Release 3 ARexx Macro                      */
  3. /* $VER: CalcReportWidth 1.1 (22.10.95)                  */
  4. /* © 1995 SoftWood, Inc.                                 */
  5. /* Use of this macro is strictly at the user's risk.     */
  6. /*                                                       */
  7. /* This macro determines what the report width will need */
  8. /* to be in order for all the columns that will be       */
  9. /* printed to fit in the report. It takes into consider- */
  10. /* ation the left margin, whether or not row numbers and */
  11. /* memos are to be printed. Be sure these are set in     */
  12. /* your report prefs before using the macro.             */
  13. /*                                                       */
  14. /* To use the macro, set up the database just as though  */
  15. /* you were going to print it (i.e. adjust the column    */
  16. /* positions and widths, select the rows or columns you  */
  17. /* want printed, etc). Run the macro using FD's ARexx    */
  18. /* menu. A requester will pop up with the report width   */
  19. /* needed.                                               */
  20. /*                                                       */
  21. /* With this width, you can tell whether or not the      */
  22. /* report will extend beyond your page. You can also use */
  23. /* it to decide which pitch to use.                      */
  24. /*                                                       */
  25. /* History:                                              */
  26. /* V1.0: Initial version.                                */
  27. /* V1.1: Modified for hidden columns for FD3.            */
  28. /* ----------------------------------------------------- */
  29.  
  30. OPTIONS RESULTS
  31.  
  32. /* ---- Determine the number of columns in the database. ---- */
  33. NumColumns
  34. ncols = RESULT
  35. IF ( ncols = 0 ) THEN DO
  36.    ShowMessage 1 1 '"No columns defined in database!" "" "" "OK" "" ""'
  37.    EXIT 10
  38. END
  39.  
  40. /* ----  Determine which columns to use in our calculations. ---- */
  41. firstCol = 1
  42. lastCol = ncols
  43. DO c = firstCol TO lastCol
  44.    GetColumnID POSITION c
  45.    cid = RESULT
  46.    /* We don't want to use the column if it is hidden. */
  47.    IsColumnHidden COLUMNID cid
  48.    IF ( RESULT ) THEN
  49.       useCol.c = 0;
  50.    ELSE
  51.       useCol.c = 1;
  52. END
  53.  
  54. SelectionInfo
  55. PARSE VAR RESULT selType selFrom selTo
  56. IF ( selType = "COLUMNS" ) THEN DO
  57.    firstCol = selFrom
  58.    lastCol = selTo
  59.  
  60.    DO c = firstCol TO lastCol
  61.       IsColumnSelected c
  62.       useCol.c = RESULT
  63.    END
  64. END
  65.  
  66. /* ---- Collect report's left margin and options ---- */
  67. GetReportPrefs LEFTMARGIN OPTIONS
  68. PARSE VAR RESULT left optFlags
  69.  
  70. /* ---- Are memo columns to be included in calculations? ---- */
  71. includeMemoWidth = 0
  72. IF ( INDEX(optFlags, "M") = 0 ) THEN
  73.    includeMemoWidth = 1
  74.  
  75. /* ---- Calculate the minimum report width needed. ---- */
  76. totwidth = 1
  77. DO c = firstCol TO lastCol
  78.    IF ( useCol.c ) THEN DO
  79.       GetColumnID POSITION c
  80.       cid = RESULT
  81.       GetColumnDef cid WIDTH TYPE
  82.       PARSE VAR RESULT colwidth coltype
  83.       IF ( coltype = "Memo" & includeMemoWidth = 0 ) THEN
  84.          ITERATE
  85.       colwidth = TRUNC((colwidth / 8))
  86.       totwidth = totwidth + colwidth + 1
  87.    END
  88. END
  89.  
  90. /* ---- If row numbers are to be included, then ---- */
  91. /* ---- we need to add more width on for them.  ---- */
  92. /* ---- Also add on for any left margin here.   ---- */
  93. IF ( INDEX(optFlags, "N") ~= 0 ) THEN DO
  94.    NumRows
  95.    totwidth = totwidth + LENGTH( RESULT ) + 1
  96. END
  97. totwidth = totwidth + left
  98.  
  99. /* ---- Display the width ---- */
  100. firstline  = '"' || 'Report Width: ' || totwidth || '"'
  101. ShowMessage 1 0 firstline '"" "" "OK" "" ""'
  102.