Just to make it as simple as possible as I am guessing you are new to Caché
ClassMethod Export(pGlobal, pFile)
{
set file=##class(%File).%New(pFile)
do file.Open("WN")
set key=$order(^Global1(""))
while key'="" {
do file.WriteLine(^Global1key))
set key=$order(^Global1(key))
}
do file.%Save()
}
$ORDER() is a command that returns the next defined subscript value. When you pass in "" it returns the first defined subscript value, 1 in your case. After writing the value of ^Global1(n) to the file the final $ORDER() will return "" indicating there are no more defined subscript values.
for more details see our docs for $ORDER()
- Log in to post comments