• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: A newbie's problems with Pages and Applescript
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A newbie's problems with Pages and Applescript


  • Subject: Re: A newbie's problems with Pages and Applescript
  • From: KOENIG Yvan <email@hidden>
  • Date: Thu, 4 Nov 2010 16:00:04 +0100


Le 3 nov. 2010 à 23:53, alma-services.abel.co.uk a écrit :


On 3 Nov 2010, at 07:39, KOENIG Yvan wrote:

You made nothing wrong.
It's a 10.5 bug.


Ahhhhhhhhh.  Merci mille fois.  I was spent a lot of time in the Spring wondering what I was doing wrong, and now I _finally_ discover, it's a bug in Leopard.  I'll just put up with relying on people to choose the right file.

I very much appreciate your web site's (.mac site?) numerous examples, and your open-handed clarity when researching mailing-list problems.  Again, many thanks.

May the force be with you,

Sandy

Here is the piece of code which I use in my own scripts :

--=====

property permittedK4 : {"com.apple.iWork.keynote.sffkey", "com.apple.iWork.keynote.sffkth"}
property permittedK5 : {"com.apple.iwork.keynote.key", "com.apple.iwork.keynote.kth"}
property permittedKey : permittedK5 & permittedK4
(* Keynote documents are treated differently *)

property permitted4 : {"com.apple.iWork.pages.sffpages", "com.apple.iWork.pages.sfftemplate", "com.apple.iwork.numbers.sffnumbers", "com.apple.iWork.numbers.sfftemplate"} & permittedK4
property permitted5 : {"com.apple.iwork.pages.pages", "com.apple.iwork.pages.template", "com.apple.iwork.numbers.numbers", "com.apple.iwork.numbers.template"} & permittedK5
property permitted : permitted5 & permitted4

--=====

on run (* 
lignes exécutées si on double clique sur l'icône du script application
• lines executed if one double click the application script's icon *)


tell application "System Events"
if my parleAnglais() then
set myPrompt to "Choose an iWork’s document"
else
set myPrompt to "Choisir un document iWork"
end if -- parleAnglais


if 5 = (system attribute "sys2") then (*
it's Mac OS X 10.5.x with a bug with Choose File *)
set allowed to {}
else (*
if Mac Os X 10.4.x or 10.6.x *)
set allowed to my permitted
end if --  5 = (system…
my commun(choose file with prompt myPrompt of type allowed) (* un alias *)
end tell
end run

--=====

on open (sel) (* 
sel contient une liste d'alias des élémentsqu'on a déposés sur l'icône du script (la sélection)
• sel contains a list of aliases of the items dropped on the script's icon (the selection) *)


my commun(item 1 of sel) (* an alias *)
end open

--=====

on commun(thePack) (*
• thePack is an alias *)
local pFold, pName, path2Index, texteXML
my nettoie()
tell application "System Events" to tell disk item (thePack as text)
set typeID to (type identifier) as text
set pFold to package folder
set pName to name
end tell


if typeID is not in my permitted then
if my parleAnglais() then
error "“" & (thePack as text) & "” is not an iWork’s document!"
else
error "«" & (thePack as text) & "» n’est pas un document iWork !"
end if -- my parleAnglais() 
end if -- typeID


if pFold then
set wasFlat to false
else
set wasFlat to true
my expandFlat(thePack) (* an alias *)
end if


if typeID is in my permittedKey then (*
special case Keynote *)
set path2Index to "" & thePack & "Index.apxl"
else (*
Pages or Numbers *)
set path2Index to "" & thePack & "Index.xml"
end if -- typeID starts …


end commun

--=====

on parleAnglais()
local z
try
tell application "Pages" to set z to localized string "Cancel"
on error
set z to "Cancel"
end try
return (z is not "Annuler")
end parleAnglais

--=====

Yvan KOENIG (VALLAURIS, France) jeudi 4 novembre 2010 15:09:37


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Re: A newbie's problems with Pages and Applescript (From: "alma-services.abel.co.uk" <email@hidden>)
 >Re: A newbie's problems with Pages and Applescript (From: "alma-services.abel.co.uk" <email@hidden>)

  • Prev by Date: Re: Invisible Unix "Icon" File
  • Next by Date: Re: Invisible Unix "Icon" File
  • Previous by thread: Re: A newbie's problems with Pages and Applescript
  • Next by thread: TreeView X and dnd Files
  • Index(es):
    • Date
    • Thread