• 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
Rép: old AppleWorks script failing under 10.5
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Rép: old AppleWorks script failing under 10.5


  • Subject: Rép: old AppleWorks script failing under 10.5
  • From: KOENIG Yvan <email@hidden>
  • Date: Fri, 8 Aug 2008 18:57:11 +0200


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)

_______________________________________________
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
  • Prev by Date: OOP AppleScript and self-initialization
  • Next by Date: Re: Unicode Bad Characters
  • Previous by thread: Re: OOP AppleScript and self-initialization
  • Next by thread: Quit App Over Time
  • Index(es):
    • Date
    • Thread