View Single Post
Success!! My old scripts are working with some changes to how I operate with notes.

Here's what I'm going to do due to time and a pile of things stacked up on my desk right now (not in Omnifocus- I need to get back on the wagon)... I'm going to up this one sample script (download link below) and this bit of explanation...

Before, my scripts were attempting to replace the full text of the note. This obviously has a problem, because there's more to a note than just text. (Not to mention it's really rich text, which always appears to be a pain in Applescript.)

This new version of my script attempts to add a paragraph to the end of the note (currently broken - I'm working on this). This last "paragraph" (line really) will then include the meta-tag you wish to add.

It appears I currently can't add a paragraph without some difficulties, so this works best on items that currently have no note. Or, if you add a single line with an & at the end of your note, you can tag the note. [Again, I hope to have this solved soon.]

WARNING- in this version, the last paragraph in your note may end up getting replaced if it happens to include the "&" symbol as the first letter of one of the lines of the note!!! [I need to add another else statement to solve this.]

This script does include sample script text from other sources, which I have not credited here. This is an oversight- if you know the source of the text included, or you are the author, please get in touch.

The point of sharing this is just this- that there is a method to include text strings, i.e., what I'll call "meta data" within notes.

The first few lines of the code can be replaced with the desired list of text items to select and tag selected notes with.

As an example...
Code:
set EnergyLevels to {"High", "Low"}
set FirstDelimiter to "&E"
set SecondDelimiter to "E"
set AddEnergyResponse to (choose from list EnergyLevels with prompt "Mark this task with Energy Level: " OK button name "Mark" without multiple selections allowed and empty selection allowed)
set mySelection to "E" & AddEnergyResponse as text
Can be edited to include things like:
Code:
{"Q1","Q2","Q3","Q4"}
(which is coming BTW), allowing you to create a dialog for tagging tasks with a subitem of a set list you use frequently.

Please note currently this script has a problem for most people with notes already- namely that it won't work unless you have no note, or if the last line of the note includes a single line with & at the beginning.

This is a good start, though.
-Allen

ps- the "insert" command apparently doesn't understand the comment "after" last character, last word, last paragraph etc. So, I can't append to the end of the note. Perhaps I'll have to make my tags at the very first line of a note. :( [should solve the problem, but is not as graceful]

Replace ".applescript" with ".scpt" (I think that's needed...)
Attached Files
File Type: applescript Energy2.applescript (11.5 KB, 479 views)