Written by

Web Developer
Question Mack Altman · Jan 25, 2017

What is the easiest way to include an INCLUDE at the beginning of each MAC routine

I am in the planning stages of making things more uniform in our routines and I would like to know what the easiest way would be to include an .inc at the beginning of each .mac routine. Has anyone written something that would open all routines and place something into the first row while leaving the rest of the routine unchanged? Thanks for any guidance you all may provide.

Comments

Dmitry Maslennikov · Jan 25, 2017

You can get list of routines with a query StudioOpenDialog in class %RoutineMgr

To edit routine you have at least two ways. Open it via class %Routine which is just a stream with a code inside. So, you can create a new stream, with a new content, and replace old one. Another way is to use commands: ZLOAD, ZINSERT, ZSAVE.

0
Mack Altman  Jan 30, 2017 to Dmitry Maslennikov

This does work for intermediate routines; however, it didn't seem to work with MAC routines. Do you know of a method for making changes to the MAC routines?

0
Manel Trèmols · Feb 3, 2017

Hi,

You can do a routine for to do it, for example:

set rou=""for {  set rou=$o(^rMAC(rou)) quit:rou=""  write !,rou  set lines=^rMAC(rou,0,0)  for x=lines:-1:2 {    set ^rMAC(rou,0,x+1)=^rMAC(rou,0,x)  }  set ^rMAC(rou,0,2)=$c(9)_"#include %occInclude"  set ^rMAC(rou,0,0)=lines+1  set ^rMAC(rou,0)=$now()  do COMPILE^%RCOMPIL(rou,"MAC",.success)}

Regards

Manel

0