Closed LinuxPad closed 4 years ago
Here the _quoteclip
snippet.
-- PURPOSE:
-- escape backslashes and double quotes and wrap the whole string in double quotes
-- use this to make a string AppleScript-friendly for setting variables/clipboard
%snippet:fnfindandreplace%
set str to the clipboard
set str to findAndReplaceInText(str, "\\", "\\\\")
set str to findAndReplaceInText(str, "\"", "\\\"")
set the clipboard to "\"" & str & "\""
Here is fnfindandreplace
, which is referenced in the above snippet:
on findAndReplaceInText(theText, theSearchString, theReplacementString)
set AppleScript's text item delimiters to theSearchString
set theTextItems to every text item of theText
set AppleScript's text item delimiters to theReplacementString
set theText to theTextItems as string
set AppleScript's text item delimiters to ""
return theText
end findAndReplaceInText
Hope that helps. FWIW, this project is just a very bare-bones example to get going with FMClipTools + TextExpander, so broken stuff like this might not be essential to getting it working.
Have you gotten this to working OS X catalina and FM 18? having a few issues.. ??
Sorry.. one more thing.. what do yo have in your quote clipboard??? I can't seem to get it to work yet...
btw.... got it working... FYI - I think github translated all the <> signs for %lt; and %gt;... after replacing them and then making another small change in script type from text to applescript.. it's all working now... thx so much for your help..
@LinuxPad Hey glad you got it working.
A quick heads up, I intentionally made the snippets prefixed with _
(underscore) text instead of AppleScript so that I could dynamically build larger AppleScripts from small text chunks.
For example, in this picture I have an AppleScript snippet, but you'll notice at the top it references %snippet:fnfindandreplace%
, which is a text snippet. By keeping small chunks as text you can combine them into other, more complex AppleScript snippets because they won't execute until embedded in that bigger AppleScript snippet.
I, and at least one other developer have run into issues like this, so my basic rule of thumb is to only make snippets AppleScript type if I'm going to run them directly, otherwise I keep them text and only use them within other snippet.
Cheers
Hey Josh... do you have this snipit you can share??