3

In the terminal, I am printing the value of a global with zw ^MYGLOBAL. How do I save this output to a text file?

senshin
  • 10,022
  • 7
  • 46
  • 59
syonip
  • 2,762
  • 25
  • 27

5 Answers5

3

Quick nasty way:

s f="c:\file.txt" o f:"wns" u f zw ^MYGLOBAL c f

The same thing, more verbosely:

set f="c:\file.txt"
open f:"wns"
use f
zwrite ^MYGLOBAL
close f
senshin
  • 10,022
  • 7
  • 46
  • 59
Paul
  • 33
  • 2
2

As you already mentioned yourself the easiest way to output global/local recursively is using ZWRITE command. Output of which could be redirected if you OPEN file and then USE it, redirecting all write to principal device to this filename.

But as Sergey @SSH mentioned elsewhere, the better approach is to use %GO utility (which essentially does the job similar to ZWRITE but output of which could be read later using %GI utility. If you want more effeciency in handling binary data then recomended approach is to output global(s) using %GOF and read them back using %GIF

Community
  • 1
  • 1
tsafin
  • 151
  • 6
1

To turn on logging, in the terminal click File → Logging, or Alt + L. This saves all the output of the terminal to a log file, until you turn off logging.

senshin
  • 10,022
  • 7
  • 46
  • 59
syonip
  • 2,762
  • 25
  • 27
1

Another option is to use the ^%GO utility. This way, you will be able to import your globals back with ^%GI.

do ^%GO
senshin
  • 10,022
  • 7
  • 46
  • 59
SSH
  • 2,533
  • 16
  • 21
1

Not exactly a ZW format, but try

do $system.OBJ.Export("Global.GLB","backup.xml")
senshin
  • 10,022
  • 7
  • 46
  • 59
Anton
  • 3,587
  • 2
  • 12
  • 27