• 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: Applescript-users Digest, Vol 3, Issue 369
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Applescript-users Digest, Vol 3, Issue 369


  • Subject: Re: Applescript-users Digest, Vol 3, Issue 369
  • From: "J. Stewart" <email@hidden>
  • Date: Fri, 21 Jul 2006 04:48:51 -0400

On 7/21/06 at +0200 Bernard Azancot said this

>Thanks.
>
>I was thinking of this kind of solution, but I do not know :
>- how a script can "read" this kind of preference file
>- what could be the preference file formating.
>
>Any hint ?

XML or plain text come to mind


>
>Michael Ghilissen, kindly replying to me from the HOT french Riviera,
>suggests the use of TextCommands (osax):
>
>tell application "TextCommands"
>	set news_text to theResult as Unicode text
>	...
>	set the news_text to (search news_text for "blah... blah..."
>replacing with "")
>end tell


TextCommands is a really good thing to have but not needed for this unless you want to get too complicated.

In it's simplest form -

This creates a file with 5 paragraphs in it.

--> Cut <--
set prefs to {"1", "2", "3", "4", "5"} -- your preferences

(* convert from list format, easier to edit in file *)
set {oldDelims, my text item delimiters} to {my text item delimiters, {return}}
set temp to items of prefs as text
set my text item delimiters to oldDelims

(* place file on the desktop (in this example) *)
set deskPath to ((path to "desk" as Unicode text) & "prefExmpl.txt")

(* write it to disk *)
try
	set fRef to open for access file deskPath with write permission
	set eof fRef to 0
	write temp to fRef
	close access fRef
on error errMsg number errNum
	close access file deskPath
	display alert ("Error # " & errNum) message errMsg buttons {"Cancel"} giving up after 5
end try
--> Cut <--


This will retrieve the info from the file created above -

--> Cut <--
set deskPath to ((path to "desk" as Unicode text) & "prefExmpl.txt")
set prefs to every paragraph of (read file deskPath)
--> Cut <--


These are the file read/write commands from the Standard Additions.osax.

JBS
--
What happens if you get scared half to death twice?
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Re: Applescript-users Digest, Vol 3, Issue 369 (From: Bernard Azancot <email@hidden>)

  • Prev by Date: Re: Applescript-users Digest, Vol 3, Issue 369
  • Next by Date: Re: Case sensitive find/replace
  • Previous by thread: Re: Applescript-users Digest, Vol 3, Issue 369
  • Next by thread: creating mailbox inside the mailbox
  • Index(es):
    • Date
    • Thread