[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: RE: .ado file questions
To (3) the answer is "Yes" if I understand you correctly.
Otherwise this is the wrong way round.
The only practical way to answer (1) fully is to write a long email
trying to explain various Stata programming concepts and why
you appear to be misunderstanding some of them. In any case
that is already very well done in the manuals. A short answer,
however, is that much of the point of temporary variables
is to rule out any question of name conflict.
(2) is unclear, at least to me, partly for similar reasons.
Show us a real example problem and your attempt at it; then
somebody should be able to explain a good solution for your example.
In any case, it may well turn out that you are trying a non-Stataish
way to solve a problem when there is a much simpler Stataish
way to do it.
> Hello everyone, I am writing a .ado file that is supposed to
> mimic what
> would be done by a "function" in other languages. The problems I'm
> running into are:
> (1) that I would like to temporarily create some extra variables but I
> don't want their names to conflict with the names of
> variables that the
> user might already have in the dataset. I.e. if I write in
> the .ado file
> "syntax varlist" to query the user for the variables he/she
> wants to use
> in calling the .ado file, and then I go through the local
> "varlist" and
> give them NAMES so that I can refer to them in the body of
> the .ado file,
> I'm worried that I might name them something that the user
> might already
> have in the dataset for something else (or even for that SAME
> Is there a way to make sure that there is no conflict in the names? I
> know there is a "tempvar" statement so that the variables
> will be dropped
> after the .ado file completes, but I am worried that they
> might actually
> not be CREATED due to the name already being used for
> something else...
> (2) Is there a way to FORCE stata to return a function after
> the .ado file
> completes? So far, I have just been creating scalars and
> matrices inside
> of the .ado file, but I think this is probably not that
> efficient for my
> purposes since I really want the function ITSELF to take on a
> value or a
> (3) If you call a .ado file from inside another .ado file,
> can I pass in
> the syntax statement from the outer file? I.e. if I write in
> the "outer"
> file that the user sees: "syntax varlist", and then call the
> inner .ado
> file as "inner `varlist'" does that make sense? I wasn't
> sure whether I
> was allowed to use this macro in this way.
* For searches and help try: