og.pr 7.74 KB
Newer Older
1
/* CIF PROCESS (149, 150), (150, 75) */
Maxime Perrotin's avatar
Maxime Perrotin committed
2
PROCESS og;
3
    /* CIF TEXT (0, 0), (298, 286) */
4
    -- A Demo to test octet strings
Maxime Perrotin's avatar
Maxime Perrotin committed
5
6
7
8
9
10
11
12
-- using various symbols.

-- check that types are case insensitive
DCL first_msg, msg my_octStr;

DCL seq SeqOf;

DCL test Some_Thing;
13
dcl foo MyInteger := 3;
Maxime Perrotin's avatar
Maxime Perrotin committed
14
15

-- Unicode comments: héhé hôhÖ
16
17
18

dcl alwaysTrue Type2 := 3 in {1,2,3};
dcl alwaysFalse Type2 := 0 in {1,2,3};
19
20

dcl seqofbool seqBool := { true, true};
21
    /* CIF ENDTEXT */
22
    /* CIF START (427, 26), (100, 50) */
23
    START;
24
        /* CIF TASK (370, 91), (214, 83) */
25
        TASK test := 5,
26
test := power(test, 1),
27
test := abs(-4+1),
Maxime Perrotin's avatar
Maxime Perrotin committed
28
test := abs(test)
29
        /* CIF COMMENT (603, 114), (183, 35) */
30
        COMMENT 'Task with unicode: voilà!';
31
        /* CIF TASK (375, 189), (204, 50) */
32
        TASK first_msg := 'Say hello first!'
33
        /* CIF COMMENT (599, 189), (148, 50) */
34
        COMMENT 'String assignment';
Maxime Perrotin's avatar
Maxime Perrotin committed
35
36
        /* CIF PROCEDURECALL (388, 254), (177, 35) */
        CALL writeln( first_msg(1,2));
37
38
39
        /* CIF PROCEDURECALL (373, 304), (207, 35) */
        CALL writeln( not (not not true));
        /* CIF TASK (394, 354), (165, 50) */
40
        TASK seq := default_seqof,
Maxime Perrotin's avatar
Maxime Perrotin committed
41
seq := {1,2,3}
42
        /* CIF COMMENT (579, 354), (204, 50) */
43
        COMMENT 'default_seqof is a constant
Maxime Perrotin's avatar
Maxime Perrotin committed
44
defined in the ASN.1 model';
45
        /* CIF TASK (345, 419), (263, 50) */
46
        TASK seq := seq // {4, test} // default_seqof
47
        /* CIF COMMENT (629, 419), (156, 50) */
48
        COMMENT 'Concatenate
Maxime Perrotin's avatar
Maxime Perrotin committed
49
two SEQUENCE OF';
50
        /* CIF TASK (408, 484), (137, 50) */
51
        TASK 'seq(1) := seq(2)';
52
53
54
        /* CIF TASK (382, 549), (189, 50) */
        TASK seq := seq(0,1) // seq(3, 4)
        /* CIF COMMENT (590, 549), (166, 50) */
55
        COMMENT 'Remove 3rd element';
56
57
58
59
60
61
62
        /* CIF TASK (407, 614), (140, 53) */
        TASK for x in seq:
    call writeln(x);
endfor;
        /* CIF PROCEDURECALL (395, 682), (164, 35) */
        CALL writeln('test=', test);
        /* CIF DECISION (425, 732), (104, 70) */
63
        DECISION test in seq
64
        /* CIF COMMENT (549, 747), (170, 39) */
65
        COMMENT 'Test the "in" operator
Maxime Perrotin's avatar
Maxime Perrotin committed
66
Unicode test: Ï';
67
                /* CIF ANSWER (335, 822), (100, 35) */
68
                (TRUE):
69
                    /* CIF PROCEDURECALL (308, 872), (154, 50) */
70
                    CALL writeln('All OK (1)');
71
                /* CIF ANSWER (498, 822), (100, 35) */
72
                (FALSE):
73
                    /* CIF PROCEDURECALL (466, 872), (164, 50) */
74
                    CALL writeln('NOT OK (1)')
75
                    /* CIF COMMENT (650, 879), (117, 35) */
76
77
                    COMMENT 'Call UnicÔDË';
        ENDDECISION;
78
79
80
81
82
        /* CIF DECISION (427, 937), (100, 70) */
        DECISION 3 in seq
        /* CIF COMMENT (547, 954), (256, 35) */
        COMMENT 'test==3 so it should also return true';
                /* CIF ANSWER (341, 1027), (100, 35) */
83
                (TRUE):
84
85
86
                    /* CIF PROCEDURECALL (309, 1077), (164, 50) */
                    CALL writeln('ALL OK (2)');
                /* CIF ANSWER (513, 1027), (100, 35) */
87
                (FALSE):
88
89
                    /* CIF PROCEDURECALL (481, 1077), (164, 50) */
                    CALL writeln('NOT OK (2)');
90
        ENDDECISION;
91
        /* CIF NEXTSTATE (427, 1142), (100, 50) */
92
        NEXTSTATE Wait;
93
    /* CIF STATE (1204, 151), (100, 50) */
94
    STATE Running;
95
        /* CIF INPUT (1204, 221), (100, 50) */
96
        INPUT go(msg);
97
            /* CIF DECISION (1202, 286), (103, 70) */
98
            DECISION msg
99
            /* CIF COMMENT (1326, 296), (111, 50) */
100
            COMMENT 'Switch-case
Maxime Perrotin's avatar
Maxime Perrotin committed
101
on strings';
102
                    /* CIF ANSWER (1454, 376), (100, 35) */
103
                    ('egg'):
104
                        /* CIF TASK (1433, 426), (141, 50) */
105
                        TASK msg := msg // '!!'
106
                        /* CIF COMMENT (1595, 426), (118, 50) */
107
                        COMMENT 'Concatenate
Maxime Perrotin's avatar
Maxime Perrotin committed
108
strings';
109
                        /* CIF OUTPUT (1429, 491), (150, 50) */
110
                        OUTPUT rezult(default_str)
111
                        /* CIF COMMENT (1594, 489), (161, 53) */
112
                        COMMENT 'Send a constant
Maxime Perrotin's avatar
Maxime Perrotin committed
113
114
defined in the ASN.1
model';
115
                        /* CIF NEXTSTATE (1454, 556), (100, 50) */
116
                        NEXTSTATE Running
117
                        /* CIF COMMENT (1574, 563), (96, 35) */
118
                        COMMENT 'Néxtaytè';
119
                    /* CIF ANSWER (878, 376), (100, 35) */
120
                    ('end'):
121
                        /* CIF OUTPUT (872, 426), (112, 50) */
122
                        OUTPUT rezult
Maxime Perrotin's avatar
Maxime Perrotin committed
123
('Goodbye!');
124
                        /* CIF NEXTSTATE (878, 493), (100, 50) */
125
                        NEXTSTATE Wait;
126
                    /* CIF ANSWER (1042, 376), (100, 35) */
127
                    ELSE:
128
                        /* CIF TASK (1021, 426), (141, 50) */
129
                        TASK msg := msg // '!'
130
                        /* CIF COMMENT (1183, 426), (118, 50) */
131
                        COMMENT 'Concatenate
Maxime Perrotin's avatar
Maxime Perrotin committed
132
strings';
133
                        /* CIF TASK (994, 491), (195, 50) */
134
                        TASK msg := msg(3,4) // msg(1,2)
135
                        /* CIF COMMENT (1210, 491), (209, 53) */
136
                        COMMENT 'Concatenate two substrings
Maxime Perrotin's avatar
Maxime Perrotin committed
137
138
(can be used to remove an
element from a list)';
139
                        /* CIF TASK (1010, 556), (163, 50) */
140
                        TASK msg := first_msg(1, 2)
141
                        /* CIF COMMENT (1186, 553), (177, 53) */
142
                        COMMENT 'Substring
Maxime Perrotin's avatar
Maxime Perrotin committed
143
144
TODO check range
against current Length';
145
                        /* CIF OUTPUT (1038, 621), (108, 50) */
146
                        OUTPUT rezult(msg);
147
                        /* CIF NEXTSTATE (1042, 686), (100, 50) */
148
149
150
                        NEXTSTATE Running;
            ENDDECISION;
    ENDSTATE;
151
    /* CIF STATE (427, 1142), (100, 50) */
152
    STATE Wait;
153
        /* CIF INPUT (427, 1212), (100, 50) */
154
        INPUT go(msg)
155
        /* CIF COMMENT (547, 1219), (120, 35) */
156
        COMMENT 'Ïñpût unicode';
157
            /* CIF DECISION (420, 1277), (114, 70) */
158
            DECISION msg = 'hello'
159
            /* CIF COMMENT (554, 1287), (128, 50) */
160
            COMMENT 'Boolean test
Maxime Perrotin's avatar
Maxime Perrotin committed
161
on string value';
162
                    /* CIF ANSWER (638, 1367), (100, 35) */
163
                    (FALSE):
164
                        /* CIF OUTPUT (618, 1417), (139, 50) */
165
                        OUTPUT rezult(first_msg)
166
                        /* CIF COMMENT (777, 1424), (85, 35) */
167
                        COMMENT 'OûtpUT';
168
                        /* CIF NEXTSTATE (638, 1482), (100, 50) */
169
                        NEXTSTATE Wait;
170
                    /* CIF ANSWER (367, 1367), (100, 35) */
171
                    (TRUE):
172
                        /* CIF OUTPUT (344, 1417), (145, 50) */
173
                        OUTPUT rezult('Welcome')
174
                        /* CIF COMMENT (509, 1417), (95, 50) */
175
                        COMMENT 'Send raw
Maxime Perrotin's avatar
Maxime Perrotin committed
176
string';
177
                        /* CIF DECISION (368, 1482), (98, 50) */
178
                        DECISION 3 in {1,2,3};
179
                                /* CIF ANSWER (328, 1552), (88, 23) */
180
                                (1 in {1,2}):
181
                                /* CIF ANSWER (418, 1552), (88, 23) */
182
183
                                (0 in {1,2}):
                        ENDDECISION;
184
                        /* CIF DECISION (368, 1590), (98, 50) */
185
                        DECISION 4 in {1,2,3};
186
                                /* CIF ANSWER (337, 1590), (70, 23) */
187
                                (true):
188
                                /* CIF ANSWER (427, 1590), (70, 23) */
189
190
                                (false):
                        ENDDECISION;
191
                        /* CIF NEXTSTATE (367, 1628), (100, 50) */
192
193
194
                        NEXTSTATE Running;
            ENDDECISION;
    ENDSTATE;
Maxime Perrotin's avatar
Maxime Perrotin committed
195
ENDPROCESS og;