help for adostore and adorestore(Roger Newson)

Store and restore the current ado-path

adostore [ global_macro_name ] [ , replace ]

adorestore [ global_macro_name ]

Description

adostore stores the current ado-file path to a global macro,
which defaults to S_ADOSTORE.
adorestore restores a stored ado-path to the current ado-file path from a global macro,
which defaults to S_ADOSTORE.
These commands enable the user to practice safe ado-path management
by storing the current ado-path before temporarily modifying the ado-path,
and restoring the stored ado-path after using the modified ado-path.

Options

replace specifies that any existing value in the global macro specified by the global_macro_name
will be overwritten.
If replace is not specified,
and the global macro specified by the global_macro_name is non-empty,
then adostore will fail.

Remarks

It is often a good idea to use the program drop _all command
immediately before or after adorestore, adopath,
or any other command that modifies the ado-path. This is because,
if you have used one version of an ado-file on one ado-path,
and then change the ado-path in order to use another version of the same ado-file,
then the first version will still be in the memory.
The program drop _all command will cause the old version to be removed from memory.
If this is done, and the ado-file is called again,
then the new version will be loaded from the new ado-path.

Note that adorestore will fail if asked to restore an ado-path
from an empty global macro,
as this would result in an empty ado-path.
If this happened, then Stata would be able to do very little,
and the best course of action would probably be to exit Stata and to start Stata again.

Examples

The following example works if the current directory has a daughter directory ./myadofiles,
containing a Stata ado-file hithere.ado,
and if no Stata ado-file hithere.ado exists on the existing ado-path.

. adopath

. adostore, replace

. program drop _all

. adopath + ./myadofiles

. hithere

. program drop _all

. adorestore

. adopath

The following example is like the previous example,
except that the existing ado-path is stored to a global macro MYOLDPATH,
instead of being stored to the default global macro S_ADOSTORE.

. adopath

. adostore MYOLDPATH, replace

. program drop _all

. adopath + ./myadofiles

. hithere

. program drop _all

. adorestore MYOLDPATH

. adopath

Author

Roger Newson, Imperial College London, UK.

Email: r.newson@imperial.ac.uk

Also see

Manual: [P] sysdir

Online: help for adopath, sysdir