help elabel protectr

Title

elabel protectr -- Protect r() results

Syntax

elabel protectr
[ , not ]

Description

elabel protectr is used in
elabel subcommands to preserve
contents in r(). elabel protectr copies the current contents
from r() and restores it when the respective command,
elabel_cmd_newcmd, concludes.

Note that elabel_cmd_newcmd must be called as

. elabel newcmd ...

for elabel protectr to work correctly.

Remarks

Say, you want to
add a command to elabel and you do
not want your command to store anything in r(). Your command, however,
needs to call other commands that do store contents in r(). Once your
command concludes, the contents in r() will be changed to whatever
other commands have stored there. Specifying elabel protectr at the
beginning of your command assures that, regardless of other commands you are
calling, the contents in r() remain unchanged after your command has
concluded.

Typical usage is

---- begin elabel_cmd_newcmd.ado

program elabel_cmd_newcmd

version

elabel protectr

...

end

---- end elabel_cmd_newcmd.ado

elabel protectr may be called within sub-programs; however,
the contents in r() will not be restored until the main program
concludes. In elabel_cmd_newcmd.ado, you may code

---- begin elabel_cmd_newcmd.ado

program elabel_cmd_newcmd

version

...

newcmd_subcmd ...

...

end

program newcmd_subcmd

elabel protectr

...

end

---- end elabel_cmd_newcmd.ado

Here, elabel protectr preserves the contents in r()
at the time newcmd_subcmd is called. However, it
is not before elabel_cmd_newcmd concludes that the
contents in r() will be restored.

Options

not specifies that previously copied contents from r()
not be restored at the command's conclusion.

Author

Daniel Klein

University of Kassel

klein.daniel.81@gmail.com

Also see

Online: _return

if installed: elabel