• 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: Scripting PLE
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Scripting PLE


  • Subject: Re: Scripting PLE
  • From: "Daniel A. Shockley" <email@hidden>
  • Date: Mon, 3 Mar 2003 09:49:07 -0500

"John S. Baltutis" <email@hidden> wrote:
Uhmmmm? Shouldn't the prefFileName be 'com.apple.ProjectBuilder.plist' vice
just 'com.apple.ProjectBuilder'?

On 3/1/03, Donald Hall <email@hidden> wrote:

You can use the defaults command to read and write properties. For example:

set theProperty to do shell script "defaults read " & "\"" &
prefFileName & "\" " & propertyName

where prefFileName is the name of the preferences file, such as
> 'com.apple.ProjectBuilder'

Actually, no. The script would be clearer if the variable was named prefDomainName, which is how the man pages for defaults refer to it. You aren't asking defaults to write to a file by path or even file name, you are asking it to write to a preference 'domain'. The defaults command can be a great way to store and retrieve preferences, although you'll need to write handlers to parse data from plist form into AppleScript form. I posted earlier about a handler I wrote that converts an array of dict into an AppleScript list of records. Here's the code (any improvements welcome):

on plistArrayOfDict(somePlistData)
-- version 1.1, Daniel A. Shockley, http://www.danshockley.com
-- NEEDs simpleReplace()
try
set parsedPlist to somePlistData

set parsedPlist to simpleReplace(parsedPlist, "{" & return & " ", "{")
set parsedPlist to simpleReplace(parsedPlist, "; " & return & " ", ",")
set parsedPlist to simpleReplace(parsedPlist, "; " & return & " }", "}")
set parsedPlist to simpleReplace(parsedPlist, " = ", ":")

set parsedPlist to "{" & text 2 thru -3 of parsedPlist & "" & return & "}"
set parsedPlist to simpleReplace(parsedPlist, return, " ")

run script parsedPlist

return result
on error errMsg number errNum
error "plistArrayOfDict FAILED: " & errMsg number errNum
end try
end plistArrayOfDict

on simpleReplace(thisText, oldChars, newChars)
-- version 1.1, Daniel A. Shockley http://www.danshockley.com
-- 1.1 coerces the newChars to a STRING,
--since other data types do not always coerce
-- (example, replacing "nine" with 9 as number replaces with "")
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to the oldChars
set the parsedList to every text item of thisText
set AppleScript's text item delimiters to the {(newChars as string)}
set the newText to the parsedList as string
set AppleScript's text item delimiters to oldDelims
return newText

end simpleReplace


--
----
Daniel A. Shockley
email@hidden
email@hidden
http://www.danshockley.com
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: limited numbers of variables?
  • Next by Date: Re: limited numbers of variables?
  • Previous by thread: Re: Scripting PLE
  • Next by thread: Date anomaly
  • Index(es):
    • Date
    • Thread