Announcement

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

  • - stop - now on SSC: It does exactly what the word implies (and a bit more)

    This new command is both completely useless and remarkably useful. It is useless because everything it does, you can also do without it. You can add an error or exit to your dofile to stop a dofile. You can close logs manually. You can even use sendtoslack to inform you that the dofile stopped. Useless!

    However, I'm going to assume that like me, there's a lot of lazy people out there, who don't want to write multiple lines in the correct order everytime they want to interrupt their dofile. People who get annoyed when Stata throws an error upon opening a log file because you forgot to close it in that small experiment you ran on the side. People who don't want to check all the time whether their dofile has finished yet, preferring instead to be notified on that one device that's never far away these days, the smartphone.

    How does stop work? That depends on the options you specify (or that you saved earlier, which is really cool imo).
    Code:
    stop
    A simple stop will close any open log files and then throw an error 1 (the same one you get when you press the break button in Stata).
    Code:
    stop, sts(https://hooks.slack.com/services/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)
    Adding a valid sendtoslack url or name will send a message to slack to indicate the dofile finished, before once again closing all logs and stopping the dofile.

    This is where it gets interesting. I am too lazy to copy that slack url each time I want to stop my dofile. That's why stop allows you to save your default options.
    Code:
    stop, sts(https://hooks.slack.com/services/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) m(Throwing in a custom message for good measure) save
    stop
    The first line saves the url as default option. The second line sends the custom message to slack, closes the logfile and stops the dofile. It will still work after you close Stata. It will still work in ten years. It won't work on a different machine (unless you copy your profile.do file). That's actually great, because it means you can customise the message by machine. In my case, I have two messages set up: one that something on my main pc finished, one that the same happened on the cluster I work on.

    The stop command also recognises saved urls from slack. Try the following.
    Code:
    sendtoslack, url("https://hooks.slack.com/services/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") saveurlas(webhooks)
    stop, sts(webhooks) m(Yep, that worked!) save
    stop
    You can see the result here.

    Any comments, feedback or bugs are very welcome. Goal for the future: play a sound/text-to-speech upon completion.
    Last edited by Jesse Wursten; 03 Jul 2018, 07:59.
Working...
X