set clipboardTex to the clipboard
set myvar to do shell script "echo " & quoted form of clipboardText & " | grep -v \"some*\"
There are many good search and replace functions here which lets you transform text much easier than with grep and sed. And faster too, since you do it “in place”. There are some tutorials in “Unscripted” as well. You want to read Advanced Text Manipulation by Julio but start with this article by Adam Bell.
Ok did some searching and started a script and i’m running into a problem. When i run the following script, the lines at the end do not change the clipboard as expected. When i take the last three lines out of the script and put it into its own script with “hello” as text, it affects the clipboard just fine. I put “hello” as text instead of the variable back into my main script just as a text, and still doesnt work. FYI i haven’t finished the InDesign manipulations part but i am able to get the text i want into the variable.
Couldn’t find anything relevant on the site about clipboard commands not working
Any thoughts? thanks for any help!
tell application “Adobe InDesign CS3”
set mySelection to selection
--clear clipboard
--account for groups
try
if (count mySelection) = 1 then
if class of item 1 of mySelection is text then set myCurrentText to selection
set myString to myCurrentText as string
set oldDelimiter to AppleScript's text item delimiters
set AppleScript's text item delimiters to "1"
set theItems to text items of myString
set AppleScript's text item delimiters to "2"
set finalText to theItems as string
-- return finalText
set AppleScript's text item delimiters to oldDelimiter
else
display dialog "select text or a text frame"
end if
on error
display dialog "there's an error!"
end try
end tell
tell application “Finder”
set the clipboard to finalText as text
end tell
I played a little bit with your cod earlier today before my internet connection went down (maintenance).
It seems to me like everything regarding delimiters and such works as it should. You should really be more concerned about the count of items from your selection. try insert some log statements.
I have one general advice to give you, and that is to make your boss or the company you work for get you a copy of Script Debugger from Late Night software. It will save you tons of working hours, especially in the beginning of your scripting career, it will save the company many times that value in productive working hours. I am not mentioning your spare time, because this must be one of the most fun and interesting ways to spend that time.
You can sit there and watch the scripts through the Debugger, and get more control, at least you’ll be able to understand what’s going on, what works and what not.
Best of all, it has a try before you by period of some three weeks.
Turns out i fixed the clipboard issue. . .not sure how, but it works. I also know i had more work to do on the counting, etc. . .still working that part out.