Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Checking if user written program is installed when programing Stata

    Dear Statalisters,

    I have two questions concerning referring to an user-written program when developing a new package:

    1- Is that an appropriate way to do (i.e. installing and running a third package when running mine)? Although it would be detailed on the help file, is that against a tacit (or explicit) rule of programming (especially the installing part)?
    Alternatively, I just indicates in the help file that my program requires foobar program to work, but it adds a step, and isn't very satisfying.

    2-If this is not against rules and habits, I'd like to add a line on the top of my program that checks whether a previous (SSC) package is installed. And therefore download it if not previously installed. What could be that line of code?

    I've first thought about:
    Code:
    ado describe foobar
    But it doesn't return a yes/no variable, only displays (or not) the description, but you can't built and if [P]command.


    Thanks,
    Charlie

  • #2
    I usually use which to look for whatever may or may not be installed.

    I would advise strongly against automatic installs of third-party packages, even if you document that.

    That's often -- indeed, usually -- best left to the user. Your part is to document that something else is needed.

    There's a third option that sometimes fits the need. You can, with the permission of the original authors, just copy their programs and make them a subroutine of yours. I've been amenable to that and/or suggested it any way. Documenting this in the help is essential.

    A variant on that is to include their programs in your package contents, any way. Again, it's clearly a good idea to consult the other authors. before doing that. I think it is generally considered fine to advertise that your program needs another, but not to include it in your package without asking.

    Yet another variant of that is that if you look hard the bit you need may be just a few lines of what you are also using. I've come across people wanting to use user-written egen functions when the nitty-gritty was just about four lines.
    Last edited by Nick Cox; 05 Dec 2016, 03:13.

    Comment


    • #3
      Thanks for your answer Nick, and for the alternatives suggested, I'll keep away from the automatic installation idea then.

      Comment

      Working...
      X