1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Method-Library
4 /*--------------------------------------------------------------------------
5 ------------------------------------------------------------------------*/
7 /* _UIB-CODE-BLOCK-END
*/
11 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
13 /* ******************** Preprocessor Definitions
******************** */
17 /* _UIB-PREPROCESSOR-BLOCK-END
*/
21 /* ************************ Function Prototypes
********************** */
23 &IF DEFINED(EXCLUDE-add-to-list) = 0 &THEN
25 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD add-to-list Method-Library
26 FUNCTION add-to-list
RETURNS CHARACTER
27 ( INPUT-OUTPUT str
AS CHAR, INPUT item
AS CHAR ) FORWARD.
29 /* _UIB-CODE-BLOCK-END
*/
34 &IF DEFINED(EXCLUDE-add-to-list-delim) = 0 &THEN
36 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD add-to-list-delim Method-Library
37 FUNCTION add-to-list-delim
RETURNS CHARACTER
38 ( INPUT-OUTPUT str
AS CHAR, INPUT item
AS CHAR, INPUT delim
AS CHAR ) FORWARD.
40 /* _UIB-CODE-BLOCK-END
*/
45 &IF DEFINED(EXCLUDE-SPC) = 0 &THEN
47 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD SPC Method-Library
48 FUNCTION SPC
RETURNS CHARACTER
49 ( INPUT n
AS INT ) FORWARD.
51 /* _UIB-CODE-BLOCK-END
*/
56 &IF DEFINED(EXCLUDE-WRAP) = 0 &THEN
58 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION-FORWARD WRAP Method-Library
59 FUNCTION WRAP
RETURNS CHARACTER
60 ( INPUT unwrapped
AS CHAR, INPUT wrap-width
AS INT ) FORWARD.
62 /* _UIB-CODE-BLOCK-END
*/
68 /* *********************** Procedure Settings
************************ */
70 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
71 /* Settings for
THIS-PROCEDURE
75 Add Fields to
: Neither
76 Other Settings
: INCLUDE-ONLY
78 &ANALYZE-RESUME _END-PROCEDURE-SETTINGS
80 /* ************************* Create Window
************************** */
82 &ANALYZE-SUSPEND _CREATE-WINDOW
83 /* DESIGN Window definition
(used by the UIB
)
84 CREATE WINDOW Method-Library
ASSIGN
87 /* END WINDOW DEFINITION
*/
94 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Method-Library
97 /* *************************** Main Block
*************************** */
99 /* _UIB-CODE-BLOCK-END
*/
103 /* ************************ Function Implementations
***************** */
105 &IF DEFINED(EXCLUDE-add-to-list) = 0 &THEN
107 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION add-to-list Method-Library
108 FUNCTION add-to-list
RETURNS CHARACTER
109 ( INPUT-OUTPUT str
AS CHAR, INPUT item
AS CHAR ) :
110 /*------------------------------------------------------------------------------
113 ------------------------------------------------------------------------------*/
115 str
= str
+ (IF str
= "" THEN "" ELSE ",") + item.
119 &GLOB EXCLUDE-add-to-list 1
121 /* _UIB-CODE-BLOCK-END
*/
126 &IF DEFINED(EXCLUDE-add-to-list-delim) = 0 &THEN
128 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION add-to-list-delim Method-Library
129 FUNCTION add-to-list-delim
RETURNS CHARACTER
130 ( INPUT-OUTPUT str
AS CHAR, INPUT item
AS CHAR, INPUT delim
AS CHAR ) :
131 /*------------------------------------------------------------------------------
134 ------------------------------------------------------------------------------*/
136 str
= str
+ (IF str
= "" THEN "" ELSE delim
) + item.
140 &GLOB EXCLUDE-add-to-list-delim 1
142 /* _UIB-CODE-BLOCK-END
*/
147 &IF DEFINED(EXCLUDE-SPC) = 0 &THEN
149 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION SPC Method-Library
150 FUNCTION SPC
RETURNS CHARACTER
152 /*------------------------------------------------------------------------------
155 ------------------------------------------------------------------------------*/
157 RETURN FILL( " ", n
).
/* Function return value.
*/
163 /* _UIB-CODE-BLOCK-END
*/
168 &IF DEFINED(EXCLUDE-WRAP) = 0 &THEN
170 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION WRAP Method-Library
171 FUNCTION WRAP
RETURNS CHARACTER
172 ( INPUT unwrapped
AS CHAR, INPUT wrap-width
AS INT ) :
173 /*------------------------------------------------------------------------------
174 Purpose
: Wrap 'unwrapped' to the specified width
175 ------------------------------------------------------------------------------*/
176 DEF VAR result
AS CHAR NO-UNDO INITIAL "".
177 DEF VAR words-left
AS CHAR NO-UNDO.
178 DEF VAR idx
AS INT NO-UNDO.
179 DEF VAR idx2
AS INT NO-UNDO.
181 words-left
= unwrapped.
182 DO WHILE LENGTH( words-left
) > wrap-width
:
183 idx
= R-INDEX( words-left
, " ", wrap-width
).
184 IF idx
= 0 THEN idx
= wrap-width.
185 idx2
= INDEX( words-left
, "~n").
186 IF idx2
<> 0 AND idx2
< idx
THEN DO:
188 result
= result
+ SUBSTR( words-left
, 1, idx
).
191 result
= result
+ TRIM(SUBSTR( words-left
, 1, idx
- 1)) + "~n".
193 words-left
= SUBSTR( words-left
, idx
+ 1).
195 result
= result
+ words-left.
203 /* _UIB-CODE-BLOCK-END
*/