[Date Prev][Date Next]
[Thread Prev][Thread Next]
[Date Index]
[Thread Index]
[New search]
To: Chris Scheck <xcom@xxxxxxxxx>, framers@xxxxxxxxxxxxxx
Subject: Re: Scripting FrameMaker
From: Larry Kollar <Larry.Kollar@xxxxxxxxxxx>
Date: Fri, 27 Oct 2000 12:37:54 -0400
In-Reply-To: <LYRIS-45500-7485-2000.10.24-10.41.20--Larry.Kollar#arris-i.com@lists.frameusers.com>
Sender: owner-framers@xxxxxxxxx
Earlier this week, Chris Scheck wrote: [Sorry about the late response. It's been a hectic week here.] >Who can help me understand how to read the file >"Applescript_Reference.pdf"? Are you at all familiar with AppleScript? If not, you need to go to <http://www.apple.com/applescript/> and start reading there. Three things are aren't immediately obvious, but are crucial to AppleScripting FrameMaker: - a book consists of a list of book components - a document keeps its text in text flows -- usually "text flow 1" unless you have a document with multiple flows - "active document" or "active book" refer to the frontmost window -- if you're working with a book, make sure it's up front, for example; Another thing that isn't immediately obvious -- if you're working with the clipboard (copy/paste) **at all**, you need to make sure the target application is active. BTW, clipboard operations affect the active document in FrameMaker. Also, use the Script Editor's "Open Dictionary" command (in the File menu) and select FrameMaker to see what all it can do. >I'm currently trying to select all text of a document, to copy it, and to >paste it into a different file. The index and explanations won't help me. >Page 107 refers to "contents of selection". But the index has no entry >for that, nor does this term crop up elsewhere. Here's a very simple script that copies all the text from a Frame doc, creates a new one, and pastes it: tell application "FrameMaker+SGML 6.0" activate -- bring app to the front select text flow 1 of active document -- same as "select all" copy -- copy the text set foo to (make new document) -- new doc is now active paste -- paste it end tell >My ultimate goal is the following: open all FM files in the specified >folder. Copy the text of each file to one new target file. Save that >"compiled" (one) target file as text. Building on the previous example, the following will paste contents of an active document into a new file then save it as text. Note that you have to create the file before you can save to it -- we do that with the Finder. Looping through an entire folder is left as an exercise to the reader (textbook-speak for "I'm too lazy to do it all for you" :-). -- create a file on the desktop set targ to ((path to desktop as text) & "foo.fm") try tell application "Finder" make file at desktop with properties {name:"foo.fm"} end tell on error -- don't bother, it's there already end try tell application "FrameMaker+SGML 6.0" activate select text flow 1 of active document copy set foo to (make new document) paste save foo in (targ as alias) as text end tell >And to all Mac'ers out there: the MIFfing example works fine, except that >I always need to specify where FrameMaker 6 is located. How can I enter >the correct path while avoiding conflicts with the example script >fragments? Sounds like your script is locked (read-only). Try running it from the Script Editor, then saving it after you tell it where to find FM. Larry ** To unsubscribe, send a message to majordomo@omsys.com ** ** with "unsubscribe framers" (no quotes) in the body. **