home *** CD-ROM | disk | FTP | other *** search
- /* ----------------------------------------------------- */
- /* Final Data Release 3 ARexx Macro */
- /* $VER: CalcReportWidth 1.1 (22.10.95) */
- /* © 1995 SoftWood, Inc. */
- /* Use of this macro is strictly at the user's risk. */
- /* */
- /* This macro determines what the report width will need */
- /* to be in order for all the columns that will be */
- /* printed to fit in the report. It takes into consider- */
- /* ation the left margin, whether or not row numbers and */
- /* memos are to be printed. Be sure these are set in */
- /* your report prefs before using the macro. */
- /* */
- /* To use the macro, set up the database just as though */
- /* you were going to print it (i.e. adjust the column */
- /* positions and widths, select the rows or columns you */
- /* want printed, etc). Run the macro using FD's ARexx */
- /* menu. A requester will pop up with the report width */
- /* needed. */
- /* */
- /* With this width, you can tell whether or not the */
- /* report will extend beyond your page. You can also use */
- /* it to decide which pitch to use. */
- /* */
- /* History: */
- /* V1.0: Initial version. */
- /* V1.1: Modified for hidden columns for FD3. */
- /* ----------------------------------------------------- */
-
- OPTIONS RESULTS
-
- /* ---- Determine the number of columns in the database. ---- */
- NumColumns
- ncols = RESULT
- IF ( ncols = 0 ) THEN DO
- ShowMessage 1 1 '"No columns defined in database!" "" "" "OK" "" ""'
- EXIT 10
- END
-
- /* ---- Determine which columns to use in our calculations. ---- */
- firstCol = 1
- lastCol = ncols
- DO c = firstCol TO lastCol
- GetColumnID POSITION c
- cid = RESULT
- /* We don't want to use the column if it is hidden. */
- IsColumnHidden COLUMNID cid
- IF ( RESULT ) THEN
- useCol.c = 0;
- ELSE
- useCol.c = 1;
- END
-
- SelectionInfo
- PARSE VAR RESULT selType selFrom selTo
- IF ( selType = "COLUMNS" ) THEN DO
- firstCol = selFrom
- lastCol = selTo
-
- DO c = firstCol TO lastCol
- IsColumnSelected c
- useCol.c = RESULT
- END
- END
-
- /* ---- Collect report's left margin and options ---- */
- GetReportPrefs LEFTMARGIN OPTIONS
- PARSE VAR RESULT left optFlags
-
- /* ---- Are memo columns to be included in calculations? ---- */
- includeMemoWidth = 0
- IF ( INDEX(optFlags, "M") = 0 ) THEN
- includeMemoWidth = 1
-
- /* ---- Calculate the minimum report width needed. ---- */
- totwidth = 1
- DO c = firstCol TO lastCol
- IF ( useCol.c ) THEN DO
- GetColumnID POSITION c
- cid = RESULT
- GetColumnDef cid WIDTH TYPE
- PARSE VAR RESULT colwidth coltype
- IF ( coltype = "Memo" & includeMemoWidth = 0 ) THEN
- ITERATE
- colwidth = TRUNC((colwidth / 8))
- totwidth = totwidth + colwidth + 1
- END
- END
-
- /* ---- If row numbers are to be included, then ---- */
- /* ---- we need to add more width on for them. ---- */
- /* ---- Also add on for any left margin here. ---- */
- IF ( INDEX(optFlags, "N") ~= 0 ) THEN DO
- NumRows
- totwidth = totwidth + LENGTH( RESULT ) + 1
- END
- totwidth = totwidth + left
-
- /* ---- Display the width ---- */
- firstline = '"' || 'Report Width: ' || totwidth || '"'
- ShowMessage 1 0 firstline '"" "" "OK" "" ""'
-