Really, this should be it, for the passing income.
[capital-apms-progress.git] / inc / string.i
blob44f6ebb12a48cdc5e6ed90f780763f1a6d4ddb95
1 &ANALYZE-SUSPEND _VERSION-NUMBER UIB_v8r12
2 &ANALYZE-RESUME
3 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _DEFINITIONS Method-Library
4 /*--------------------------------------------------------------------------
5 ------------------------------------------------------------------------*/
7 /* _UIB-CODE-BLOCK-END */
8 &ANALYZE-RESUME
11 &ANALYZE-SUSPEND _UIB-PREPROCESSOR-BLOCK
13 /* ******************** Preprocessor Definitions ******************** */
17 /* _UIB-PREPROCESSOR-BLOCK-END */
18 &ANALYZE-RESUME
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 */
30 &ANALYZE-RESUME
32 &ENDIF
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 */
41 &ANALYZE-RESUME
43 &ENDIF
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 */
52 &ANALYZE-RESUME
54 &ENDIF
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 */
63 &ANALYZE-RESUME
65 &ENDIF
68 /* *********************** Procedure Settings ************************ */
70 &ANALYZE-SUSPEND _PROCEDURE-SETTINGS
71 /* Settings for THIS-PROCEDURE
72 Type: Method-Library
73 Allow:
74 Frames: 0
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
85 HEIGHT = .08
86 WIDTH = 38.72.
87 /* END WINDOW DEFINITION */
89 &ANALYZE-RESUME
94 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _CUSTOM _MAIN-BLOCK Method-Library
97 /* *************************** Main Block *************************** */
99 /* _UIB-CODE-BLOCK-END */
100 &ANALYZE-RESUME
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 /*------------------------------------------------------------------------------
111 Purpose:
112 Notes:
113 ------------------------------------------------------------------------------*/
115 str = str + (IF str = "" THEN "" ELSE ",") + item.
117 END FUNCTION.
119 &GLOB EXCLUDE-add-to-list 1
121 /* _UIB-CODE-BLOCK-END */
122 &ANALYZE-RESUME
124 &ENDIF
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 /*------------------------------------------------------------------------------
132 Purpose:
133 Notes:
134 ------------------------------------------------------------------------------*/
136 str = str + (IF str = "" THEN "" ELSE delim) + item.
138 END FUNCTION.
140 &GLOB EXCLUDE-add-to-list-delim 1
142 /* _UIB-CODE-BLOCK-END */
143 &ANALYZE-RESUME
145 &ENDIF
147 &IF DEFINED(EXCLUDE-SPC) = 0 &THEN
149 &ANALYZE-SUSPEND _UIB-CODE-BLOCK _FUNCTION SPC Method-Library
150 FUNCTION SPC RETURNS CHARACTER
151 ( INPUT n AS INT ) :
152 /*------------------------------------------------------------------------------
153 Purpose:
154 Notes:
155 ------------------------------------------------------------------------------*/
157 RETURN FILL( " ", n ). /* Function return value. */
159 END FUNCTION.
161 &GLOB EXCLUDE-SPC 1
163 /* _UIB-CODE-BLOCK-END */
164 &ANALYZE-RESUME
166 &ENDIF
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:
187 idx = idx2.
188 result = result + SUBSTR( words-left, 1, idx).
189 END.
190 ELSE
191 result = result + TRIM(SUBSTR( words-left, 1, idx - 1)) + "~n".
193 words-left = SUBSTR( words-left, idx + 1).
194 END.
195 result = result + words-left.
197 RETURN result.
199 END FUNCTION.
201 &GLOB EXCLUDE-WRAP 1
203 /* _UIB-CODE-BLOCK-END */
204 &ANALYZE-RESUME
206 &ENDIF