Kbase 13248: Version 7 and 8: Example as how to print an Editor Widget.
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  10/05/1998 |
|
Version 7 and 8: Example as how to print an Editor Widget.
Below is an example as how to print an Editor Widget in Progress
version 7 and 8. It does not print page-numbers, but it does allow you
to control left margin, and number of characters to print on a
line.
This notebook is intended to give inspiration, and is by no means
complete.
The procedure to print a string is called "TxtPrt.p" and is called
with 3 parameters:
1. INTEGER, left margin
2. INTEGER, number of character per line
3. CHARACTER, text string
/* TxtPrt.p */
DEF INPUT PARAMETER x_margin AS INT NO-UNDO.
DEF INPUT PARAMETER x_maxlen AS INT NO-UNDO.
DEF INPUT PARAMETER x_txt AS CHAR NO-UNDO.
DEF VAR x_n AS INT NO-UNDO.
DEF VAR x_l AS INT NO-UNDO.
DEF VAR x_str AS CHAR NO-UNDO.
DEF VAR x_ln AS LOG NO-UNDO.
DEF VAR x_max AS INT NO-UNDO.
DEF SHARED STREAM PTV.
x_txt = x_txt + CHR(13) + CHR(10).
x_max = LENGTH(x_txt).
x_n = 1.
DO WHILE x_n < x_max:
x_str = SUBSTRING(x_txt, x_n, x_maxlen).
x_ln = FALSE.
x_l = INDEX(x_str, CHR(13) + CHR(10)).
IF x_l > 0 THEN x_ln = TRUE.
IF NOT x_ln THEN x_l = R-INDEX(x_str, " ").
IF x_l > 0 THEN DO:
PUT STREAM PTV UNFORMATTED SPACE(x_margin)
SUBSTRING(x_txt, x_n, x_l - 1) SKIP.
x_n = x_n + x_l.
if x_ln THEN x_n = x_n + 1.
END.
IF x_l = 0 THEN x_n = x_max.
END.
RETURN.
/* Main program to use this routine */
DEF NEW SHARED STREAM PTV.
DEFINE VAR WINDOW-1 AS WIDGET-HANDLE NO-UNDO.
DEFINE BUTTON BUTTON-1
LABEL "Print"
SIZE 17 BY 2.
DEFINE VARIABLE EDITOR-1 AS character
VIEW-AS EDITOR SCROLLBAR-VERTICAL
SIZE 69 BY 8 NO-UNDO.
DEFINE VARIABLE FILL-IN-1 AS INTEGER FORMAT ">9":U
LABEL "Left Margin"
VIEW-AS FILL-IN
SIZE 5 BY 1 NO-UNDO.
DEFINE VARIABLE FILL-IN-2 AS INTEGER FORMAT ">9":U
LABEL "Char Per Line"
VIEW-AS FILL-IN
SIZE 5 BY 1 NO-UNDO.
DEFINE VARIABLE FILL-IN-3 AS CHARACTER FORMAT "X(17)":U
LABEL "File Name"
VIEW-AS FILL-IN
SIZE 17 BY 1 NO-UNDO.
DEFINE FRAME FRAME-A
EDITOR-1 AT ROW 2 COL 7 NO-LABEL
FILL-IN-1 AT ROW 11 COL 24 COLON-ALIGNED
BUTTON-1 AT ROW 12 COL 58
FILL-IN-2 AT ROW 12.5 COL 24 COLON-ALIGNED
FILL-IN-3 AT ROW 14 COL 22 COLON-ALIGNED
WITH 1 DOWN NO-BOX OVERLAY SIDE-LABELS
AT COL 1 ROW 1
SIZE 82 BY 16.
CREATE WINDOW WINDOW-1 ASSIGN
TITLE = "Window 1"
COLUMN = 13.43
ROW = 6.08
HEIGHT = 16
WIDTH = 82
MAX-HEIGHT = 16
MAX-WIDTH = 82
VIRTUAL-HEIGHT = 16
VIRTUAL-WIDTH = 82
RESIZE = yes
SCROLL-BARS = yes
STATUS-AREA = yes
BGCOLOR = ?
FGCOLOR = ?
MESSAGE-AREA = no
SENSITIVE = yes.
ON CHOOSE OF BUTTON-1 IN FRAME FRAME-A /* Print */
DO:
/* Example for using TxtPrt.p */
OUTPUT STREAM PTV TO VALUE(FILL-IN-3:SCREEN-VALUE).
RUN ./TxtPrt.p (INPUT INTEGER(FILL-IN-1:SCREEN-VALUE),
INPUT INTEGER(FILL-IN-2:SCREEN-VALUE),
INPUT EDITOR-1:SCREEN-VALUE).
OUTPUT STREAM PTV CLOSE.
MESSAGE "Output was printed.." VIEW-AS ALERT-BOX.
APPLY "ESC" TO current-window.
END.
ASSIGN
CURRENT-WINDOW = WINDOW-1
SESSION:SYSTEM-ALERT-BOXES =
(WINDOW-1:MESSAGE-AREA = NO).
ASSIGN
FILL-IN-1 = 5
FILL-IN-2 = 60
FILL-IN-3 = "test.txt" .
PAUSE 0 BEFORE-HIDE.
DISPLAY FILL-IN-1 FILL-IN-2 FILL-IN-3
WITH FRAME FRAME-A IN WINDOW WINDOW-1.
ENABLE EDITOR-1 FILL-IN-1 BUTTON-1 FILL-IN-2 FILL-IN-3
WITH FRAME FRAME-A IN WINDOW WINDOW-1.
VIEW WINDOW-1.
WAIT-FOR WINDOW-CLOSE OF WINDOW-1.
DELETE WIDGET WINDOW-1.
RETURN
Progress Software Technical Support Note # 13248