Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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



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:
http://lists.apple.com/mailman/options/applescript-users/email@hidden

This email sent to email@hidden

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



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.