-- Note: Snow Leopard/Rosetta screws up open of template file, thank you Apple property page_wide : 8 * 72 -- USA 8.5" minus two 1/4" margins property page_tall : 10.5 * 72 -- USA 11" minus two 1/4" margins property text_font : "Courier" property text_size : 8 tell application "Finder" to set project_folder to container of (path to me) as string set the_listing to open_listing given template:project_folder & "ListingTemplate.cws" global the_page_number set the_page_number to 0 list_files out of (get_file_names given folder:project_folder & "classes") onto the_listing -- Could do other folders in the project here -- Add files (of types we know about, including optional header files) to listing to list_files out of list_of_names onto the_listing repeat with file_name in list_of_names if "m" = name extension of file_name then list_file from (text 1 thru -3 of (file_name as string) & ".h") at 20 between "// pragma page" on the_listing given bump:0 list_file from file_name at 300 between "// pragma page" on the_listing given bump:1 else if "mm" = name extension of file_name then list_file from (text 1 thru -4 of (file_name as string) & ".h") at 20 between "// pragma page" on the_listing given bump:0 list_file from file_name at 300 between "// pragma page" on the_listing given bump:1 -- Could add "else if" clauses for other recognized file types here end if end repeat end list_files -- Expand folder into filenames to get_file_names given folder:the_folder tell application "Finder" to return files of folder the_folder end get_file_names -- List starting at vertical_position after spltting text in file file_name at new_page_marker and initial pbump to list_file on the_listing from file_name at vertical_position between new_page_marker given bump:page_bump set file_text to read file (file_name as string) set prevTIDs to AppleScript's text item delimiters set AppleScript's text item delimiters to new_page_marker set the_pages to text items of file_text set AppleScript's text item delimiters to prevTIDs set text_prefix to "" repeat with a_page in the_pages tell application "AppleWorks 6" set newframe to make new text frame at front in drawing layer of the_listing with properties {bounds:{the_page_number * page_wide, vertical_position, (the_page_number + 1) * page_wide, vertical_position + page_tall}} with data text_prefix & a_page set size of text body of newframe to text_size set font of text body of newframe to text_font -- my showrect("textblock", bounds of newframe) -- select every character of (text body of newframe) set foo to bounds of newframe -- display dialog ((item 4 of foo) - (item 2 of foo)) as string end tell set vertical_position to 20 set text_prefix to new_page_marker set the_page_number to the_page_number + page_bump set page_bump to 1 end repeat end list_file -- Use template (stationery) until we figure out how to -- 1. setup running page numbers in footer -- 2, set document width to multiple pages on open_listing given template:template_name tell application "AppleWorks 6" activate try open file template_name set new_listing to document "untitled" on error set new_listing to make new document at "desktop" with properties {document kind:drawing document, name:"untitled"} set header of new_listing to "Listing " & (current date) end try -- my showrect("listing", margins of listing) end tell return new_listing end open_listing