Skip to content

Commit b67edaa

Browse files
Merge pull request #1 from SylvainGuilbaud:embedded-python
add embedded python method
2 parents 6720f29 + 01d1e94 commit b67edaa

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

src/dc/sample/ObjectScript.cls

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,43 @@ Class dc.sample.ObjectScript
22
{
33

44
ClassMethod Test() As %Status
5+
{
6+
set sc = $$$OK
7+
Try {
8+
set sc = ..Run() ; Python
9+
set sc = ..Run(0) ; ObjectScript
10+
}
11+
Catch ex {
12+
set sc=ex.AsStatus()
13+
}
14+
return sc
15+
}
16+
17+
ClassMethod Run(python As %Boolean = 1) As %Status
18+
{
19+
return:python ..Python()
20+
return:'python ..ObjectScript()
21+
}
22+
23+
ClassMethod ObjectScript() As %Status
524
{
625
set a=42
7-
write "Hello World!",!
26+
write "Hello World! from ",$CLASSMETHOD("dc.sample.ObjectScript","%ClassName",1)," in ObjectScript language",!
827
write "This is InterSystems IRIS with version ",$zv,!
9-
write "Current time is: "_$zdt($h,2),!
28+
write "Current time is: "_$zdt($now(),2,,6),!
1029
return a
1130
}
1231

32+
ClassMethod Python() As %Status [ Language = python ]
33+
{
34+
import iris
35+
from datetime import datetime
36+
a=42
37+
print("Hello World! from",iris.cls('dc.sample.ObjectScript')._ClassName(1),"in Python language")
38+
print("This is InterSystems IRIS with version",iris.cls('%SYSTEM.Version').GetVersion())
39+
now = datetime.now()
40+
print("Current time is:",now)
41+
return a
42+
}
43+
1344
}

0 commit comments

Comments
 (0)