-
Notifications
You must be signed in to change notification settings - Fork 7
/
example.prg
57 lines (48 loc) · 1.46 KB
/
example.prg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
SET PROCEDURE TO python ADDITIVE
start_python()
args = CREATEOBJECT('PythonTuple', 'arg1', 2)
?args.repr()
retval = PythonFunctionCall('example_module', 'swap_args', args)
?retval.repr()
r1 = retval.getitem(0)
r2 = retval.getitem(1)
?r1, r2
RELEASE r1, r2, retval
args = CREATEOBJECT('PythonTuple', 'arg1')
kwargs = CREATEOBJECT('PythonDictionary')
kwargs.setItem('arg2', 2)
?args.repr()
?kwargs.repr()
retval = PythonFunctionCall('example_module', 'swap_args', args, kwargs)
?retval.repr()
r1 = retval.getitem(0)
r2 = retval.getitem(1)
?r1, r2
RELEASE kwargs, r1, r2, retval
example_dict = CREATEOBJECT('PythonDictionary')
example_dict.setItem('key1', .NULL.)
example_dict.setItem('key2', .T.)
example_dict.setItem('key3', 3.5)
example_dict.setItem('key4', DATE())
?example_dict.repr()
?example_dict.getitem('key4')
RELEASE example_dict
example_list = CREATEOBJECT('PythonList')
example_list.callMethod('append', CREATEOBJECT('PythonTuple', .NULL.))
example_list.callMethod('append', CREATEOBJECT('PythonTuple', .T.))
example_list.callMethod('append', CREATEOBJECT('PythonTuple', 3.5))
example_list.callMethod('append', CREATEOBJECT('PythonTuple', DATETIME()))
?example_list.repr()
?example_list.getitem(3)
example_list.setitem(2, 3.6)
?example_list.repr()
?example_list.getitem(2)
RELEASE example_list
&&generate an error
example_list = CREATEOBJECT('PythonList')
?example_list.getitem(0)
?example_list.setitem(0, 5)
RELEASE example_list
stop_python()
RELEASE PROCEDURE python
RETURN