Re: Use XML to create extensible data structures in text fields?
Re: Use XML to create extensible data structures in text fields?
- Subject: Re: Use XML to create extensible data structures in text fields?
- From: Michael Grant <email@hidden>
- Date: Fri, 24 Nov 2017 21:56:22 -0600
OK, this is looking promising. I downloaded an app called JSON Helper from
the app store. Apart from a few minor quirks (numbers in the JSON tend to
come out as 22.949999999999999 instead of 22.95, and it won't accept actual
AppleScript dates, but date strings are fine), this might end up being
easier than I thought. The script below writes (more or less) the expected
JSON data into the notes field of a selected OmniFocus task:
--
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
tell application id "com.omnigroup.OmniFocus2" -- OmniFocus.app
tell front window
set theTask to value of item 1 of (selected trees of content)
set taskName to name of theTask
end tell
end tell
tell application "System Events"
activate
try
set theBudget to (text returned of (display dialog "Enter budget for “" &
taskName & "”:" default answer "0.00") as real)
set softDeadline to (text returned of (display dialog "Enter target date
for “" & taskName & "”:" default answer "1/1/2001"))
end try
end tell
set extendedData to {budget:theBudget, soft:softDeadline}
tell application id "com.vidblishen.jsonhelper" -- JSON Helper.app
set resultText to make JSON from extendedData
end tell
tell application id "com.omnigroup.OmniFocus2" -- OmniFocus.app
tell theTask
if note is "" then
set note to resultText
else
set note to note & "
=============================
" & resultText
end if
end tell
end tell
--
I think Shane had an AppleScriptObjC handler somewhere to create dialogs
with multiple text entry fields — will have to dig that up. Add some error
handling to make sure the text input is really what's wanted. Since I'll
probably be the only one using it, it doesn't have to be all that robust.
Overall it looks like the input part will actually be pretty easy.
I also vaguely remember seeing code somewhere that lets the user choose a
contact from the Contacts database. I'll want to add that at some point so
I can include a client link in the extended data for a task.
Next step will be code to read and work with the JSON data once it's in
there. Parsing and extracting the JSON from other text in the note field
shouldn't be too hard. Then I suppose I'll want to copy some of the
"native" task parameters along with the JSON data into a spreadsheet or
maybe something like OmniOutliner so I can actually sum and sort and
otherwise manipulate the extended data....
Michael
On Fri, Nov 24, 2017 at 8:10 PM, Michael Grant <email@hidden> wrote:
> I'm familiar with it but I don't see how it's relevant for what I'm trying
> to do. What do you have in mind?
>
> Michael
>
> On Fri, Nov 24, 2017 at 6:09 PM, James Yost <email@hidden>
> wrote:
>
>> Michael, have you ever taken a look at DEVONThink Pro?
>>
>> It is highly scriptable with hundreds of example scripts, and it can take
>> almost any kind of data or files.
>>
>> If you want to read about what it can do, see their websites downloads
>> page and download the manual.
>>
>> Regards
>> James
>>
>> > On Nov 24, 2017, at 3:31 PM, Michael Grant <email@hidden> wrote:
>> >
>> > All else being equal, better human readability is certainly a plus.
>> > Michael
>> >
>>
>>
>
>
> --
> There's really no such thing as translating. It's all a scam. We basically
> just make stuff up and try to make it sound plausible.
>
--
There's really no such thing as translating. It's all a scam. We basically
just make stuff up and try to make it sound plausible.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden