I’m trying to create a shortcut to track alcohol consumption. So far I can enter and convert 1 drink at a time but can’t get the running daily total to work.
Also, I am assuming the daily total variable will stay in memory from one day to the next; I want it to reset to zero at midnight every night. Any help with this too would be appreviated. TIA!
I know it’s possible to save info to the Shortcuts folder, but this idea should work with Sheets too.
Try saving a document that has the current date on the top line, data on subsequent lines.
Read the file and split it by line so you can parse the first line easily. If its first line is today, use the data as a starting point, update it, then save it.
If its first line is not today, discard it and save today’s data.
So I’ve learned that Shortcuts does not store variables in memory between activations. Thus, it seems my incremental daily total is just resetting to zero every time I run the shortcut. Am going to try writing to clipboard as a way to retain a dynamic total between activations. Hope this works!
I would suggest you either save to a file or log this data to Health as a way to store it. The clipboard can easily be removed or corrupted and isn’t a great way to store data.
I’d been meaning to try out this method (saving data) and I had a little time, so here’s a skeleton you could adapt.
Currently it increments a number from 1 each day, resetting to 1 at the start of a new day.
It could just as easily log a wealth of info, putting each piece on a new line.
If it’s the amount of alcohol (ml/oz) rather than the drink (beer, wine, etc) you’re recording then, as @RosemaryOrchard suggests, creating entries in the Health app would be the way to go. Shortcuts has an actions to create the entires for each amount, and generate a total for the day based on those entries.
Thanks for the feedback everybody. I know it’s been forever but I’ve had this on the back burner. Has become quite a complex shortcut. Still working out some math whenever I have some time, hope to post soon… final product should post data to Health as well as Sheets. Have been using comments to cite actual research papers I’ve been collecting, would like to get this right.