Question
Sadagopan Srinivasan · Nov 9, 2016

How to set the Current Directory

Hi,

I have a requirement to replace $ZF("%ZSET_DIR","/hold/rsm") to its equivalent Cache Class. The $ZF("%ZSET_DIR") sets the Current folder equivalent to "cd" command in Unix.

Can anyone help on this, please

Thanks & Regards,

Sadagopan TS

00
1 0 5 669
Log in or sign up to continue

Replies

you can do it with this command

set oldPath=##class(%SYSTEM.Process).CurrentDirectory(newPath) 

Many Thanks for your command. It works fine. Looks it will not work in Cache 2008 and it will work only in Cache 2015

That Cache class is not available in Cache 2008.2. However, it does work in Cache 2010.2 and 2012.2 so it is available in at least 2010.2 and later versions of Cache.

Also, that class call can be used to retrieve the current directory by not including the new path in the call, e.g.:

set oldPath=##class(%SYSTEM.Process).CurrentDirectory()

The current directory is now in the oldPath variable, e.g.:

w oldPath

c:\intersystems\cache\mgr\user\

You can also use syntax:

 set currPath=$SYSTEM.Process.CurrentDirectory()
 set oldPath=$SYSTEM.Process.CurrentDirectory(newPath)

The CurentDirectory method is an API covering the internal $ZUTIL functions:

ClassMethod CurrentDirectory(dir As %String) As %String
{
 quit:'$d(dir) $zu(168)
 quit $zu(168,dir)
}

Therefore in older Caché versions you can use:

set currPath=$ZU(168)
 set oldPath=$ZU(168,newPath)