Question Anna Golitsyna · Oct 8, 2021

Object script analog of RCOPY

I am trying to figure out the best ObjectScript analog to mimic, more or less, the %RCOPY functionality. What would be ObjectScript  method(s) if any to copy a routine from the current namespace to another one and compile it there?

Product version: Caché 2017.1

Comments

Anna Golitsyna  Oct 8, 2021 to Chris Eslinger

That would make the routine from namespace A immediately available in namespace B as is. The goal is to have routines in two namespaces different until the time comes for the programmer to make them the same via an RCOPY analog. It is also a "per routine" job used for synchronizing.

0
Anna Golitsyna  Oct 8, 2021 to Marc Mundt

Thanks! Let's see if there are less "clunky" ways smiley

0
Anna Golitsyna  Oct 8, 2021 to Marc Mundt

Marc, a slight variation on your idea, tested whether targetRtn exists or not. Thanks again!

zn "A"
currRtn=(##class(%Routine).%OpenId(rtnName))
stream=currRtn.Read()
zn "B"
targetRtn=(##class(%Routine).%OpenId(rtnName))
sc=targetRtn.Write(stream)
targetRtn.Save()

0
Robert Cemper · Oct 9, 2021

What's bad about using %RCOPY if you want it ?

0
Eduard Lebedyuk  Oct 9, 2021 to Robert Cemper

I think OP needs non-interactive approach.

0
Anna Golitsyna  Oct 11, 2021 to Robert Cemper

Robert, it does not trigger source control and yes, I'd like it non-interactive too.

0
Anna Golitsyna  Oct 11, 2021 to Robert Cemper

Also %RCOPY preserves date modified of the original routine, and I'd rather preserve it. So far other listed approaches do not preserve it.

0
Stephen Head · Oct 11, 2021

Probably a bit old-fashioned and maybe too simple, but this still works:

x "zl @rtn zn tns zs @rtn"

where rtn is the routine name and tns contains the name of the 'to' namespace.

0
Anna Golitsyna  Oct 11, 2021 to Stephen Head

Yes, that works and assigns the time of copy as the date modified. Thanks, Stephen! BTW, in my experience at least some old-fashioned commands are faster than their modern equivalents though in this case the speed is not an issue.

0
Alexey Maslov  Oct 12, 2021 to Anna Golitsyna

That approach works only for *.INT routines. Don't you use *.MAC and *.INC as well?

0