You are not logged in. You can browse but not post. Login or Register by clicking 'Login or Register' at the top-right of this page. For more information on Statalist, see the FAQ.
Nick Cox When collaborating, someone may change the program without warning. So when i run the program i would like it to reload itself before it does anything. Do you think this is possible?
I am quite possibly not getting this. But If your collaborators do that, you need different rules of collaboration, or different collaborators. Seriously.
It's a strong personal rule never to write a program with someone else without mutual trust and some protocol for flagging to each other what you have done. The optimum number of collaborators is 1. (But many people work in different ways.)
Also, and again seriously, how can anything you write protect your program against changes by someone else? I suppose what you could do is (e.g.) put your program on ssc and then download it in the code you give. But then your collaborator is likely to get confused.
I am getting more puzzled here. This isn't a matter on which opinions are any use. I do use discard interactively. I haven't tried putting discard in the middle of a program; that seems an odd thing to want to do. You'd need to experiment to see what happens.
We've moved in 11 minutes from "does not seem to work" to "does not work". I am not surprised either way. Other ideas I think would be more likely with precise code examples and more detail on what you want.
I am not sure whether i can be more clear on this. I want to reload an ado file containing a program. Because the program in the ado file may change, i would like the ado file with the program to be reloaded into memory every time i run the program. For example:
Code:
program foo
discard
foo
.
.
.
end
Unfortunately, discard does not work. The program does not reload before it continues. I was wondering if i can force Stata to reload the program from the ado file while the same program is still running.
before the program statement. Say we have foo.ado defining the program foo like
Code:
capture program drop foo
program foo
...
end
Now assume there is another program foo already loaded in memory. Stata will always execute this latter program and not even look for foo.ado. Only if there is currently no program foo in memory will the ado file be executed. But then there is no need to drop a non-existing program, of course.
It seems the same reasoning applies to Belinda's problem. The discard statement, even if it did work, would never be executed, once another program foo is loaded in memory. Maybe a worked example of what "did not work" means here would help along with an explanation of what the expected outcome would have been.
A good reason for program drop foo is that you are editing a program progressively, removing a bug or adding a feature at each iteration. (Or, as often in my experience, failing to do either.) So, you're saying, No, use this version of the program, not the one you have in memory. Once the program is stable it loses that rationale.
I have been using program drop and still use it a lot, precisely when I am changing things and re-run the code as if it was a regular do-file (another place where you can have programs and where dropping them before definition is a valid option) to define the program over and over, manually. However, in an ado-file that is treated as such, i.e. not run manually but automatically, it just does not make any sense to put this statement as the first line.
I still do not fully understand Belinda's situation.
I have been using program drop and still use it a lot, precisely when I am changing things and re-run the code as if it was a regular do-file (another place where you can have programs and where dropping them before definition is a valid option) to define the program over and over, manually.
The idea is to make this process happen automatically. I would be happy to settle for something less, for example when i run foo, the program to reload the foo.ado and exit. But i am not sure if even this is possible?
Comment