home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD1.iso / Database / FDATA3-1.DMS / in.adf / FDMacros / SetColumnWidth < prev    next >
Encoding:
Text File  |  1995-03-08  |  2.5 KB  |  80 lines

  1. /* --------------------------------------------- */
  2. /* Final Data ARexx Macro.                       */
  3. /* SetColumnWidth: This macro will adjust the    */
  4. /*  width of each selected column so that when   */
  5. /*  printed all of the data in the column will   */
  6. /*  be printed.                                  */
  7. /*                                               */
  8. /* $VER: SetColumnWidth 1.2 (8.3.95)             */
  9. /* © 1995 SoftWood, Inc.                         */
  10. /*                                               */
  11. /* This macro is useful because the font used on */
  12. /*  screen is proportional, whereas the printed  */
  13. /*  font is non-proportional (mono-spaced). This */
  14. /*  makes it difficult to know how wide to make  */
  15. /*  the column so that all the data will get     */
  16. /*  printed. Without this macro it's all done by */
  17. /*  trial and error.                             */
  18. /*                                               */
  19. /* Changes:                                      */
  20. /*  V1.1  Initial version for Final Data.        */
  21. /*  v1.2  Modified for Final Data R2 to support  */
  22. /*        non-contiguous column selection. Also  */
  23. /*        has options to reselect columns.       */
  24. /* --------------------------------------------- */
  25. OPTIONS RESULTS
  26.  
  27. reselect = 0   /* 1 to reselect columns after sizing them */
  28.                /* 0 to leave columns unselected.          */
  29.  
  30. SelectionInfo
  31. PARSE VAR RESULT selType fromCol toCol
  32.  
  33. IF ( selType = 'COLUMNS' ) THEN DO
  34.  
  35.    NumRows
  36.    nrows = RESULT
  37.    IF ( nrows > 0 ) THEN DO
  38.  
  39.       /* Determine which columns are selected. */
  40.       DO c = fromCol TO toCol
  41.          IsColumnSelected c
  42.          columnSelected.c = RESULT
  43.       END
  44.  
  45.       /* Change the widths of selected columns. */
  46.       DO c = fromCol TO toCol
  47.          IF ( columnSelected.c ) THEN DO
  48.             GetColumnName POSITION c
  49.             maxlen = LENGTH(RESULT)
  50.  
  51.             DO r = 1 TO nrows
  52.                CellData c r
  53.                len = LENGTH(RESULT)
  54.                IF ( len > maxlen ) THEN
  55.                   maxlen = len
  56.             END /* do to nrows */
  57.  
  58.             pixels = (maxlen * 8) + 1
  59.             IF ( pixels > 640 ) THEN
  60.                pixels = 640
  61.             GetColumnID POSITION c
  62.             InitModifyColumn RESULT
  63.             DefineColumn WIDTH pixels
  64.             ModifyColumn
  65.          END
  66.  
  67.       END /* DO to toCol */
  68.  
  69.       IF ( reselect ) THEN DO
  70.          /* Reselect the columns. */
  71.          DO c = fromCol TO toCol
  72.             IF ( columnSelected.c ) THEN DO
  73.                SelectColumn c EXTEND
  74.             END
  75.          END
  76.       END
  77.  
  78.    END
  79.  
  80. END