1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Method-Library
4 /*--------------------------------------------------------------------------
6 Purpose
: Methods for producing HTML-based reports
7 Author
(s
) : Andrew McMillan
8 Notes
: This should be a replacement for m-txtrep.i
, except
9 that it probably _won't_ work on the batch queue.
10 and lot's of other changes will be needed to work
11 for a different metaphor really.
12 ------------------------------------------------------------------------*/
14 DEF VAR htmlrep-print-file
AS CHAR NO-UNDO.
15 DEF VAR htmlrep-header-file
AS CHAR NO-UNDO.
16 DEF VAR htmlrep-filename
AS CHAR NO-UNDO.
17 DEF VAR htmlrep-prefix
AS CHAR INITIAL "R" NO-UNDO.
19 DEF VAR htmlrep-headers
AS CHAR NO-UNDO INITIAL "<html>~n".
20 DEF VAR htmlrep-body
AS CHAR NO-UNDO INITIAL "</head>~n".
21 DEF VAR htmlrep-hdr-sent
AS LOGI
NO-UNDO INITIAL No.
22 DEF VAR htmlrep-current-tag
AS CHAR NO-UNDO INITIAL "".
24 /* _UIB-CODE-BLOCK-END
*/
28 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
30 /* ******************** Preprocessor Definitions
******************** */
34 /* _UIB-PREPROCESSOR-BLOCK-END
*/
38 /* ************************ Function Prototypes
********************** */
40 &IF DEFINED(EXCLUDE-html-entities) = 0 &THEN
42 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD html-entities Method-Library
43 FUNCTION html-entities
RETURNS CHARACTER
44 ( INPUT base-text
AS CHAR ) FORWARD.
46 /* _UIB-CODE-BLOCK-END
*/
51 &IF DEFINED(EXCLUDE-tag) = 0 &THEN
53 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD tag Method-Library
54 FUNCTION tag
RETURNS CHARACTER
55 ( INPUT tagtype
AS CHAR, INPUT tagtext
AS CHAR, INPUT attributes
AS CHAR ) FORWARD.
57 /* _UIB-CODE-BLOCK-END
*/
63 /* *********************** Procedure Settings
************************ */
65 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
66 /* Settings for
THIS-PROCEDURE
70 Add Fields to
: Neither
71 Other Settings
: INCLUDE-ONLY
73 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
75 /* ************************* Create Window
************************** */
77 &ANALYZE-SUSPEND _CREATE-WINDOW
78 /* DESIGN Window definition
(used by the UIB
)
79 CREATE WINDOW Method-Library
ASSIGN
82 /* END WINDOW DEFINITION
*/
86 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _INCLUDED-LIB Method-Library
87 /* ************************* Included-Libraries
*********************** */
89 {inc
/method
/m-bqmgr.i
}
90 {src
/adm
/method
/attribut.i
}
93 /* _UIB-CODE-BLOCK-END
*/
100 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Method-Library
103 /* *************************** Main Block
*************************** */
105 RUN htmlrep-initialise.
107 /* _UIB-CODE-BLOCK-END
*/
111 /* ********************** Internal Procedures
*********************** */
113 &IF DEFINED(EXCLUDE-htmlrep-initialise) = 0 &THEN
115 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE htmlrep-initialise Method-Library
116 PROCEDURE htmlrep-initialise
:
117 /*------------------------------------------------------------------------------
118 Purpose
: Initialise the important parameters
119 ------------------------------------------------------------------------------*/
120 DEF VAR temp-dir
AS CHAR NO-UNDO.
122 temp-dir
= OS-GETENV("TEMP":U
).
123 IF temp-dir
= ?
OR temp-dir
= "" THEN temp-dir
= SESSION:TEMP-DIRECTORY .
124 temp-dir
= temp-dir
+ "\".
126 htmlrep-print-file
= temp-dir
+ "HB" + STRING( TIME, "99999") + ".TMP".
127 htmlrep-header-file
= temp-dir
+ "HH" + STRING( TIME, "99999") + ".TMP".
128 htmlrep-filename
= temp-dir
+ "H" + STRING( TIME, "99999") + ".html" .
130 DO WHILE INDEX( htmlrep-print-file
, "/" ) > 0:
131 SUBSTRING( htmlrep-print-file
, INDEX( htmlrep-print-file
, "/" ), 1) = "\".
133 DO WHILE INDEX( htmlrep-header-file
, "/" ) > 0:
134 SUBSTRING( htmlrep-header-file
, INDEX( htmlrep-header-file
, "/" ), 1) = "\".
136 DO WHILE INDEX( htmlrep-filename
, "/" ) > 0:
137 SUBSTRING( htmlrep-filename
, INDEX( htmlrep-filename
, "/" ), 1) = "\".
140 htmlrep-headers
= "<html>~n<head>~n".
144 /* _UIB-CODE-BLOCK-END
*/
149 &IF DEFINED(EXCLUDE-htmlrep-line) = 0 &THEN
151 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE htmlrep-line Method-Library
152 PROCEDURE htmlrep-line
:
153 /*------------------------------------------------------------------------------
154 Purpose
: Print a line in a selected font
155 ------------------------------------------------------------------------------*/
156 DEF INPUT PARAMETER line-text
AS CHAR NO-UNDO.
158 IF line-text
= ?
THEN line-text
= "".
160 DEF VAR i
AS INT NO-UNDO.
162 htmlrep-body
= htmlrep-body
+ line-text
+ "~n".
164 /* PUT UNFORMATTED line-text
SKIP.
*/
168 /* _UIB-CODE-BLOCK-END
*/
173 &IF DEFINED(EXCLUDE-pclrep-start) = 0 &THEN
175 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE pclrep-start Method-Library
176 PROCEDURE pclrep-start
:
177 /*------------------------------------------------------------------------------
179 ------------------------------------------------------------------------------*/
180 DEF INPUT PARAMETER preview
AS LOGICAL NO-UNDO.
182 htmlrep-headers
= "<html>~n".
183 htmlrep-body
= "</head>~n".
187 /* _UIB-CODE-BLOCK-END
*/
192 &IF DEFINED(EXCLUDE-set-title) = 0 &THEN
194 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE set-title Method-Library
195 PROCEDURE set-title
:
196 /*------------------------------------------------------------------------------
197 Purpose
: Set the title in the report viewer window.
198 ------------------------------------------------------------------------------*/
199 DEF INPUT PARAMETER title-text
AS CHAR NO-UNDO.
201 htmlrep-headers
= htmlrep-headers
202 + "<title>" + html-entities
(title-text
) + "</title>~n".
206 /* _UIB-CODE-BLOCK-END
*/
211 &IF DEFINED(EXCLUDE-view-output-file) = 0 &THEN
213 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _PROCEDURE view-output-file Method-Library
214 PROCEDURE view-output-file
:
215 /*------------------------------------------------------------------------------
216 Purpose
: Close the output file now that we've finished with it.
217 ------------------------------------------------------------------------------*/
218 DEF INPUT PARAMETER txtrep-is-preview
AS LOGI
NO-UNDO.
220 OUTPUT TO VALUE(html-filename
) .
221 PUT UNFORMATTED htmlrep-headers htmlrep-body .
224 IF txtrep-is-preview
THEN DO:
225 OS-COMMAND "iexplore " + htmlrep-filename .
233 /* _UIB-CODE-BLOCK-END
*/
238 /* ************************ Function Implementations
***************** */
240 &IF DEFINED(EXCLUDE-html-entities) = 0 &THEN
242 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION html-entities Method-Library
243 FUNCTION html-entities
RETURNS CHARACTER
244 ( INPUT base-text
AS CHAR ) :
245 /*------------------------------------------------------------------------------
246 Purpose
: Convert awkward characters to HTML entities
248 ------------------------------------------------------------------------------*/
249 DEF VAR replaced
AS CHAR NO-UNDO.
251 replaced
= REPLACE( base-text
, "&", "&" ).
252 replaced
= REPLACE( replaced
, "<", "<" ).
253 replaced
= REPLACE( replaced
, ">", ">" ).
259 /* _UIB-CODE-BLOCK-END
*/
264 &IF DEFINED(EXCLUDE-tag) = 0 &THEN
266 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION tag Method-Library
267 FUNCTION tag
RETURNS CHARACTER
268 ( INPUT tagtype
AS CHAR, INPUT tagtext
AS CHAR, INPUT attributes
AS CHAR ) :
269 /*------------------------------------------------------------------------------
270 Purpose
: Enclose the tagtext value in quotes
272 ------------------------------------------------------------------------------*/
274 RETURN "<" + tagtype
+ " " + attributes
+ ">"
276 + "</" + tagtype
+ ">".
280 /* _UIB-CODE-BLOCK-END
*/