Article View: adobe.scripting.indesign
Article #15628[AS, ID2] Getting clipboard to list format
From: Dianna_Bearce
Date: Wed, 26 Nov 2003 17:51
Date: Wed, 26 Nov 2003 17:51
71 lines
3085 bytes
3085 bytes
Okay. I'm working on my first script. I have a CD case insert, and on every copy of it, there needs to be a random number. I have a list of random numbers from our database admin, delimited by commas. So this script is supposed to get the number of items on the clipboard, make a new page for each one, and enter the code on each page.
The script is conditional upon (1) the ID document being open and (2) there being a list of comma delimited items on the clipboard, such as "aa,bb,cc".
My problem is that I can't seem to get AppleScript to recognize the clipboard items as a list. With the script I've posted below, it only makes one page and puts the entire list in that text box.
In another try of my script (which I wish now I'd saved), it would recognize each character as a list item, so it would put one character on each page.
Here is my present script.
set AppleScript's text item delimiters to ","
set myList to the clipboard
set numList to text items of myList
set numberOfItems to (number of text items in numList)
tell application "InDesign 2.0.2"
activate
set myDocument to active document
set pages per document of document preferences of myDocument to numberOfItems
repeat with x from 1 to numberOfItems
tell page x of myDocument
set myFrame to make text frame
tell myFrame
set geometric bounds to {24.486111111111, 9.881944444444, 25.569444444445, 23.881944444444}
set contents to text item x of numList
set the vertical justification of text frame preferences to bottom
end tell
end tell
end repeat
end tell
I did some troubleshooting and it seems that it's the list variable that's having problems. Look at the following test script I wrote, and pretend that the clipboard contains "aa,bb,cc":
set AppleScript's text item delimiters to ","
set theText to the clipboard
set newText to text items of theText
theText
It returns the result:
"aa,bb,cc"
But when I try typing in the list instead of getting it off the clipboard, like this, it works fine.
set theText to {"aa","bb","cc"}
set AppleScript's text item delimiters to ","
set newText to text items of theText
newText
Result:
{"aa", "bb", "cc"}
I hope someone can help me out. I feel like I've hit a wall, but also feel like the answer shouldn't be so complicated.
Technical Details
Message-ID:
<2cce9d04.-1@webx.la2eafNXanI>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!skynet.be!news.tele.dk!news.tele.dk!small.news.tele.dk!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!webxShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f939a,30b86ee8a363a210,start X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2003-11-26 10:07:53 PST From: Dianna_Bearce@adobeforums.com Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!skynet.be!news.tele.dk!news.tele.dk!small.news.tele.dk!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!webx Newsgroups: adobe.scripting.indesign Subject: [AS, ID2] Getting clipboard to list format Message-ID: <2cce9d04.-1@webx.la2eafNXanI> Date: Wed, 26 Nov 2003 09:51:38 -0800 Lines: 67 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit