Project

General

Profile

7184.p

Vladimir Tsichevski, 12/15/2025 02:51 PM

Download (1.87 KB)

 
1
BLOCK-LEVEL ON ERROR UNDO, THROW.
2

    
3
USING OpenEdge.Core.Assert.
4

    
5
/**
6
 * Convert CHARACTER to  LONGCHAR
7
 */
8
FUNCTION CLc RETURNS LONGCHAR
9
   (INPUT c AS CHARACTER):
10

    
11
   RETURN c.
12
END FUNCTION.
13

    
14
/**
15
 * Return LONGCHAR argument unchanged
16
 */
17
FUNCTION Lc RETURNS LONGCHAR
18
   (INPUT c AS LONGCHAR):
19

    
20
   RETURN c.
21
END FUNCTION.
22

    
23
/**
24
 * Concat CHARACTER with LONGCHAR, return LONGCHAR
25
 */
26
FUNCTION CLcLc RETURNS LONGCHAR
27
   (INPUT c AS CHARACTER,
28
    INPUT lc AS LONGCHAR):
29

    
30
   RETURN c + lc.
31
END FUNCTION.
32

    
33
@Test.
34
PROCEDURE test1:
35
   DEFINE VARIABLE lc AS LONGCHAR NO-UNDO.
36
   DEFINE VARIABLE lcr AS LONGCHAR NO-UNDO.
37
   
38
   ASSIGN lc = 'qwerty'
39
          lcr = 'asdfqwerty'.
40
   Assert:Equals(lcr, CLcLc('asdf', lc)).
41
   Assert:Equals(lcr, CLcLc('asdf', 'qwerty')).
42

    
43
   Assert:Equals(lcr, Lc("asdf" + "qwerty")).
44

    
45
   lcr = "asdf".
46
   Assert:Equals(lcr, Lc("asdf")).
47
   
48
   lcr = "asdfqwerty".
49
   
50
   // And this parameter converts to CHARACTER instead of LONGCHAR
51
   Assert:Equals(lcr, Lc("asdf" + "qwerty")).
52
   Assert:Equals(lcr, Lc("asdf" + lc)).
53
   
54
   Assert:Equals(lc, Lc(lc)).
55

    
56
   lcr = "a'sdf" + 'qwe"rty'.
57
   Assert:Equals(lcr, Lc("a'sdf" + 'qwe"rty')).
58

    
59
   lcr = 'as"df' + "qwe'rty".
60
   Assert:Equals(lcr, Lc('as"df' + "qwe'rty")).
61

    
62
   lcr = 'as"df' + 'qwe"rty'.
63
   Assert:Equals(lcr, Lc('as"df' + 'qwe"rty')).
64
   
65
   // Now three arguments
66
   lcr = 'as"df' + 'qwe"rty' + "third arg".
67
   Assert:Equals(lcr, Lc('as"df' + 'qwe"rty' + "third arg")).
68

    
69
   // nested mixed expression
70
   lcr = 'asdf' + STRING('qwerty') + 'zxcv'.
71
   Assert:Equals(lcr, Lc('asdf' + STRING('qwerty') + 'zxcv')).
72
   
73
   DEFINE VARIABLE ch AS CHARACTER NO-UNDO.
74
   DEFINE VARIABLE ch2 AS CHARACTER NO-UNDO.
75
   
76
   lcr = "a" + ch + "B" + "c" + ch2.
77
   Assert:Equals(lcr, Lc("a" + ch + "B" + "c" + ch2)).
78
   
79
   lcr = "a" + "b" + Lc("c" + "d" + "e") + "f" + "g".
80
   Assert:Equals(lcr, Lc("a" + "b" + Lc("c" + "d" + "e") + "f" + "g")).
81

    
82
END.
83

    
84