syonip
syonip

Reputation: 2971

How do you save the value of a global to a text file with Intersystems Caché?

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

Upvotes: 3

Views: 1315

Answers (5)

Paul
Paul

Reputation: 33

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

Upvotes: 3

syonip
syonip

Reputation: 2971

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.

Upvotes: 1

SSH
SSH

Reputation: 2553

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

do ^%GO

Upvotes: 1

Anton
Anton

Reputation: 4052

Not exactly a ZW format, but try

do $system.OBJ.Export("Global.GLB","backup.xml")

Upvotes: 1

tsafin
tsafin

Reputation: 151

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

Upvotes: 2

Related Questions