Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Clip to Evernote via Quicksilver and AppleScript' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Clip to Evernote via Quicksilver and AppleScript
Authored by: jedverity on Nov 01, '08 10:05:21AM

Sorry! Here is a replacement with that fixed.


--begin code

property defaults : {notebook:"", tags:"", title:""}
property special_delim : ";"

global txt, pspecial, cpos

using terms from application "Quicksilver"
on process text qtxt
my mainprogram(qtxt)
end process text
end using terms from

on initvars(qtxt)
copy qtxt to txt
set pspecial to 10000000
end initvars

on mainprogram(qtxt)
my initvars(qtxt)
set ztags to getdata("tags:", defaults's tags)
set znotebook to getdata("nb:", defaults's notebook)
set ztitle to gettitle()
if pspecial < txt's length then
set pend to (pspecial - 2)
else
set pend to txt's length
end if
set znote to getnote(pend)
set ztags to itemize(ztags, " ")
--return {ztitle, znote, znotebook, ztags}
my CreateEvernote(ztitle, znote, znotebook, ztags)
end mainprogram

to CreateEvernote(t, n, nb, tg)
if nb ≠ "" then
tell application "Evernote" to create note with text n title t notebook nb tags tg
else
tell application "Evernote" to create note with text n title t tags tg
end if
end CreateEvernote

to getdata(label, default)
set o to offset of label in txt
if o > 0 then
if o < pspecial then
set pspecial to o
end if
set chunk to my trim(itemize(txt, label)'s item 2 as string)
if label = "nb:" then
set nxt to "tags:"
else
set nxt to "nb:"
end if
set chunk to my trim(itemize(chunk, nxt)'s item 1 as string)
if (offset of special_delim in chunk) is not false then
return itemize(chunk, special_delim)'s item 1
else
return chunk
end if
else
return default
end if
end getdata

to getnote(meta_start_pos)
try
set start_pos to cpos + 1
on error
set start_pos to 1
end try
if start_pos > meta_start_pos then
return ""
else
return my trim(text start_pos thru meta_start_pos of txt)
end if
end getnote

to gettitle()
set title to my getdata("title:", defaults's title)
if title = "" then
set cpos to offset of ":" in txt
if cpos > 0 then
set title to my trim(text 1 thru (cpos - 1) of txt)
end if
end if
return title
end gettitle

to itemize(var, delim)
set delims_old to AppleScript's text item delimiters
set AppleScript's text item delimiters to delim
if var's class = list then
set txt_new to var as text
else
set txt_new to var's text items
end if
set AppleScript's text item delimiters to delims_old
return txt_new
end itemize

on trim(someText)
repeat until someText does not start with " "
set someText to text 2 thru -1 of someText
end repeat

repeat until someText does not end with " "
set someText to text 1 thru -2 of someText
end repeat

return someText
end trim

--end code



[ Reply to This | # ]