· Feb 24, 2020 2m read

Show globals in Excel

In MX any global can be displayed on a sheet in the form of a table.

We will look at the simplest example (work only with  CACHE-2014+ or IRIS)

Upgrade or install  MX.

Start mx.xlsb  and connect to your namespase with vmx-routines.

After opening first sheet, click button  []   ##class(SYS.Stats.Dashboard).Sample()

Then press button [design-mode]   (top of screen ).

You will see something like this in the top four lines:

M-Formulas works in cells in the process of opening this sheet,  step by step :

  • - go to the namespace %SYS    ( zn “%SYS” )
  • - set dashboard=##class(SYS.Stats.Dashboard).Sample()
  • - come back    ( zn %UCI )

Next cell:

  • - open the spooler   (open 2:($j:1) use 2 ),   zw dashboard , come back  to principal device  ( use 0 )  
  • - set the read index to the begin of the spooler   ( set z="^SPOOL($j,0)" )

Next cell: ( located in the area of ​​table construction)

  • - read the lines,  but print only those in which there is a  ‘=’  sign
  •                 ?_%mxIndex ; for row=1:1:999 set z=$$getObj(z,1),%mxIndex=z   q:'$l(z)  set rr=@z  q:rr[" = "
  • - if  ‘OK’  or  ‘Normal’  then set font green  ( set formating  tag  ‘<mx fc10 ‘ )
  •                 ?_q oo ; if q["OK"!(q["orma") set oo=oo_"<mx fc10 "

Spooler reading stops if  %mxIndex=’’ 

As a result, global mapped to excel :

You can change formulas and observe the effect. If change,  then click design-mode for save your version.

Any questions  or here.

Best wishes


Discussion (5)1
Log in or sign up to continue


I loaded the VMX programs in a different namespace. I see the picture when I run mx.xlsb. I read your instructions:

After opening first sheet, click button  []   ##class(SYS.Stats.Dashboard).Sample()

Then press button [design-mode]   (top of screen ).

I cannot tell what button to press first and the design button is not clickable.

Hi Oliver,

You're on the right track !

button  ##class(SYS.Stats.Dashboard).Sample()  see on cell  T7 (far right on 1_TEST sheet)

button [design-mode]   see top-menu of MX :

buttons top-menu left to right :  to-home-MX, mini-term-MX, print, copy-active-sheet-to-folder-C:\M, change-MX-date, design-mode, EXIT-MX