Written by

Question Phillip Wu · Mar 21, 2024

Writing "DO ^ROUTINE" code

I want to write a routine [I think this is the correct Intersystems term] call STOPALLPRODUCTIONS.

I want to be able to call the routine:

DO ^STOPALLPRODUCTIONS

Routines are described here:

https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cl…

The code will be something like:

zn "namespace1"

set status=##class(Ens.Director).StopProduction()

set status=##class(Ens.Director).GetProductionStatus()

WRITE "namespace1 production is ",$CASE(status,

              0:"Running",1:"Stopped",2:"Suspended",

              3:"Troubled")

zn "namespace2"

set status=##class(Ens.Director).StopProduction()

set status=##class(Ens.Director).GetProductionStatus()

WRITE "namespace2 production is ",$CASE(status,

              0:"Running",1:"Stopped",2:"Suspended",

              3:"Troubled")

  1. Which namespace should this code go into? I think %SYS. Is this correct?
  2. Would this code stop all my productions and print me out the production status?
  3. Would I have to put this code around my code:

STOPALLPRODUCTIONS () [PublicVariables]

{

    /* code goes here */

 }

  1. Would I put it into my DB using VS CODE like shown in the youtube videos?
Product version: IRIS 2021.1

Comments

Robert Cemper · Mar 21, 2024

Routine names starting with %Z or %z go to namespace %SYS automatically:
Though by mapping it to namespace %ALL any routine can be available in any namespace

0
Oliver Wilms · Mar 21, 2024

STOPALLPRODUCTIONS
Try {
Kill array
Do ##class(%SYS.Namespace).ListAll(.array)
Set ns = ""
For {
Set ns = $Order(array(ns))
If (ns = "") Quit
Kill x
Set = $$MyFunc(ns)
Write "x = ",x,!
}
Return
Catch {
Write $ZERROR,!
}
Quit
MyFunc(ns)
Try {
Write "ns = ",ns,!
ZN ns
Set sc1 = ##class(Ens.Director).StopProduction()
Write "sc1 = ",sc1,!
Catch {
Write $ZERROR,!
}
Return ns

0
Phillip Wu  Mar 30, 2024 to Oliver Wilms

Thanks.
Would I put this put it into my DB using VS CODE using the same procedure as putting a class [as shown in the youtube videos]?

0