Re: R?p: old AppleWorks script failing under 10.5
Re: R?p: old AppleWorks script failing under 10.5
- Subject: Re: R?p: old AppleWorks script failing under 10.5
- From: Matt Neuburg <email@hidden>
- Date: Sun, 10 Aug 2008 10:00:02 -0700
- Thread-topic: R?p: old AppleWorks script failing under 10.5
In my opinion, you should file a bug with Apple on AppleScript 10.5 for
making you do this. The backwards incompatibility that requires this sort of
song-and-dance is unacceptable. Apple was warned that this would happen if
they proceeded thoughtlessly with the move to all-Unicode-all-the-time
strings in AppleScript, and they did it anyway. m.
On Fri, 8 Aug 2008 18:57:11 +0200, KOENIG Yvan <email@hidden> said:
>
>> Le 6 août 2008 à 18:49, KOENIG Yvan a écrit :
>> â¦
>
>Hiroto TANAKA gave me the explanation an the soluce.
>
>When we run the script under 10.5, the string describing the
>translator "Word 98, 2001 Mac" is Unicode Text.
>Alas AppleWorks ignores all of this encoding. So, we must re-encode
>it as pure Text data.
>
>I edited one handler this way:
>
>-- ===========
>
>on TraiteUnFichier(leFichier)
> tell application "Finder" to set ¬
> leVraiNom to (name of alias leFichier)
> if leVraiNom ends with ".cwk" then ¬
> set leVraiNom to ¬
> (text 1 thru -5 of leVraiNom) as text
> (* ⢠strip .cwk extension *)
>
> tell application "AppleWorks 6"
> try
> open alias leFichier
> end try
> end tell -- to AppleWorks
>
> set C to my createDirTree(cheminDeStockage, "")
>
> (* ici il faut créer un nom unique *)
> set nouvoNom to my creeNomUnique(C, leVraiNom, "doc")
>
> set traducteur_ to "Word 98, 2001 Mac"
> if my quelOS() is not less than "1050" then set traducteur_ to my
>textAsStringData(traducteur_)
>
> my enregistreSous(leFichier, leTraducteur, nouveauChemin)
>
> my enregistreSous(leFichier, leTraducteur, nouveauChemin)
>
> tell application "AppleWorks 6" to ¬
> close document 1 without saving
>end TraiteUnFichier
>
>-- ===========
>
>and added two handlers:
>
>
>
>-- ===========
>
>on quelOS()
> set the hexData to system attribute "sysv"
> set hexString to {}
> repeat 4 times
> set hexString to ((hexData mod 16) as string) & hexString
> set hexData to hexData div 16
> end repeat
> return hexString as string
>end quelOS
>
>-- =============
>
>(* Merci/Thanks Hiroto *)
>
>on textAsStringData(t)
> (*
>text t : source text
>return data : «data TEXT...», where ... is hexadecimal
>representation of t as MacRoman string.
>*)
> set enTexte to do shell script "printf " & quoted form of t & " |
>iconv -f utf-8 -t macroman | perl -0777 -ne 'print unpack \"H*\", $_;'"
> run (run script "
>script
>return «data TEXT" & enTexte & "»
>end script")
>
>end textAsStringData
>
>-- =============
>
>Yvan KOENIG (from FRANCE vendredi 8 août 2008 18:07:26)
>
>
>
>
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
One of the 2007 MacTech Top 25: <http://tinyurl.com/2rh4pf>
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>
_______________________________________________
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