Setting up a function to tag scripts for notifications
2 views (last 30 days)
I have a simple notification setup that is using pbNotify from FileExchange, which sends a notification to my mobile phone via Pushbullet when a long-running script finishes. For the setup to work, I have to add a line with my token and another line containing my message. I also generally pass the elapsed time with tic-toc command couple to the message (it is really convenient!).
Now, I do not want to include the two lines of code in my scripts and comment/uncomment occasionally. I want to prepare a function that does this work "semi-automatically".
Say that I have a script called "work.m", running time of which depends on the amount of data I input. Whenever I know that the script will take a long time to process the data, I will come to the Command Window and call my script, say that it is "add_notification.m". When I call add_notification.m , the work.m script's notifications will be turned on and when I run work.m, I will always get notifications upon completion until I toggle it off. Note that I do not add anything on work.m.
I have some ideas for this to work. For example, I can get an active (in editor) script's path with:
I can use this with add_notification.m to prepare some kind of a "name pool", including the names of the scripts that I want notifications from. Then, I need to find a way to check if work.m has completed processing without adding anything into it manually. If work.m has completed, then another script, say it is called "notificate.m" runs automatically and checks if the completed script's name is included in the name pool. If the name is in the list, then I get a notification, if not, nothing happens.
Do you have any ideas? Is this possible?
I can also simplify my question into these sub-questions:
- Is it possible to "programmatically" check if a script have completed running?
- ...if it is possible, then how can I run another script right after to get notifications?