Skip to content

Instantly share code, notes, and snippets.

@lsfalimis
Last active August 29, 2015 14:02
Show Gist options
  • Save lsfalimis/c8ebe7d27e3390351f8e to your computer and use it in GitHub Desktop.
Save lsfalimis/c8ebe7d27e3390351f8e to your computer and use it in GitHub Desktop.
List 'natural language "and" list' in Tinderbox 6
(*
KM macro "Create TB Child Node" http://i.imgur.com/XMnf1bQ.png
KM macro "Create TB Node" http://i.imgur.com/zkDVSb9.png
They need to be put in a global macro group.
An item/node in Tinderbox 6 must be selected to get this AppleScript work.
The 'and' list that the AppleScript will work with looks like 'a, b, c, and d'.
So a list that looks like 'a, b, c and d' will not work.
*)
tell application "Keyboard Maestro Engine"
set theText to the clipboard as text
set AppleScript's text item delimiters to ", "
set theText to text items 1 thru -1 of theText
set j to count of theText
set k to j - 1
set itemZ to item j of theText
set kmVarRef to make variable with properties {name:"listItem"}
set value of kmVarRef to item 1 of theText
do script "Create TB Child Node"
repeat with i from 2 to k
set value of kmVarRef to item i of theText
do script "Create TB Node"
end repeat
if itemZ starts with "and " then
set itemZ to text 5 thru -1 of itemZ
end if
set value of kmVarRef to itemZ
do script "Create TB Node"
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment