Discussion (6)2
Log in or sign up to continue

Hi Evgeny,

The following is a tool System Management Specialists may use.

You can achieve Jobbing and also running arbitrary ObjectScript code by employing RunLegacyTask.

For example run arbitrary code:

USER>zw ^ABC

USER>D $SYSTEM.Python.Shell()
 
Python 3.9.5 (default, Mar 14 2023, 06:58:44) [MSC v.1927 64 bit (AMD64)] on win32
Type quit() or Ctrl-D to exit this shell.
>>> myjob=iris.cls("%SYS.Task.RunLegacyTask")._New()

>>> myjob.ExecuteCode="Set ^ABC=""123"""

>>> res=myjob.OnTask()

>>> res
1
>>> quit()

USER>zw ^ABC
^ABC=123

For example Jobbing a Routine.

Routine (Test.mac) source code:

 Test
  Set ^ABC=345
  Quit

Use legacy Task to Job it off:

USER>zw ^ABC
^ABC=123
 
USER>D $SYSTEM.Python.Shell()
 
Python 3.9.5 (default, Mar 14 2023, 06:58:44) [MSC v.1927 64 bit (AMD64)] on win32
Type quit() or Ctrl-D to exit this shell.

>>> myjob=iris.cls("%SYS.Task.RunLegacyTask")._New()
>>> myjob.ExecuteCode="Job Test^Test"
>>> res=myjob.OnTask()
>>> res
1
>>> quit()
 
USER>zw ^ABC
^ABC=345

The status result can be useful to understand problems.

For example the Routine line label "Test" was miss-typed as "TEST"

>>> myjob=iris.cls("%SYS.Task.RunLegacyTask")._New()
>>> myjob.ExecuteCode="Job TEST^Test"
>>> res=myjob.OnTask()
>>> iris.cls("%SYSTEM.Status").DisplayError(res)
 
ERROR #5001: <NOLINE>zexecuteCode+3^%SYS.Task.RunLegacyTask.11

Enjoy IRIS. No limits :)