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")
- Which namespace should this code go into? I think %SYS. Is this correct?
- Would this code stop all my productions and print me out the production status?
- Would I have to put this code around my code:
STOPALLPRODUCTIONS () [PublicVariables]
{
/* code goes here */
}
- Would I put it into my DB using VS CODE like shown in the youtube videos?
Comments
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
STOPALLPRODUCTIONS
Try {
Kill array
Do ##class(%SYS.Namespace).ListAll(.array)
Set ns = ""
For {
Set ns = $Order(array(ns))
If (ns = "") Quit
Kill x
Set x = $$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
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]?