
To store an updated variable I add the variable back to the master dictionary using the same variable name as its key, e.g.
Once the variable is extracted from the reminder (the above processes are very fast btw) I can then do what I need with it – show it in a prompt for input or do a calculation with it etc. The dictionary value itself can be anything – including another dictionary – so the scope for storing variables can extend to cover some complex scenarios. Get value for variable name from dictionary name. One of the dictionary keys is the variable name I’m interested in, so I get the value of that key. Then it gets the content of the notes of that reminder and extracts a dictionary from the note text. When I run my Shortcut it gets that reminder by name (filters to first reminder match). In that list I have a reminder called PyLog variables. This list will only ever have reminders that I use for variable storage so it won’t become unwieldy. In Reminders I’ve created a dedicated list called Reference. In the prompt is the previous reading, e.g. When adding a new meter reading the Shortcut will ask if it is an electricity / gas reading, and then it will prompt me for the reading. The Shortcut is called PyLog (because the Shortcut triggers a Python script to store my readings in text files). Here’s how I implement variable storage for a Shortcut I use to log electricity and gas meter readings. > This is my preferred method of storing variables across Shortcut runs because I always have the Reminders app installed and it’s more efficient than the Notes method. To do this we can simply use the Edit Reminder action. So variables can be stored in a master dictionary* as text. Reminders might seem a strange place to store data until you consider the fact that reminder notes can be changed not just be appended to. > The above limitation also applies to storing variables in text files directly by a Shortcut – Shortcuts can only append to text files. Eventually this will have an impact on the performance of the Shortcut. Also as the Shortcut is used over time the note contents will increase. This means you have to build in a routine to identify the last item that was appended to get the latest data payload. Once data is inserted into the note it can’t be deleted by Shortcuts.
> The major limitation here is that Shortcuts can only append to a note. Set the limit to 1 note and assign it to a variable. Just give a note a unique title and you can reliably access it using the Find Notes Where action. So a note can serve as a data repository.
I’d judge that a high proportion of iOS users have the stock Notes app installed. > This is good but I personally wanted something that wouldn’t require an app that I might not have installed all the time.
#BEST IOS SHORTCUTS 2021 FREE#
Global variables are included in the free set of functionality. This app supports a feature called Global Variables and these are available across Shortcut runs.