• 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: Property Lists <integer> tags being writing as <real>
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Property Lists <integer> tags being writing as <real>


  • Subject: Re: Property Lists <integer> tags being writing as <real>
  • From: Mark Alldritt <email@hidden>
  • Date: Wed, 28 Jul 2004 14:26:52 -0700

> In OS X 10.3.4, I have finally mostly gotten my method to turn off Energy
> Saving and then re-enable it with the old values working with the help form
> Late Night Software's Property List Tools. I am having one last issue. When
> run as a user who has rights to the plist file listed below this code works
> "almost" perfectly. If I make a copy of my PowerManagement plist and do a
> "diff -u" immediately, there is obviously no difference. However, when I run
> this code:

I've traced through this in the Property List Tools code, and here's the
problem:

When Property List tools passes the property list data to the Mac OS
(CoreFoundation) for parsing the values returned are tagged as a signed
64-bit integers. So, Property List Tools faithfully creates a 64 integer
AppleEvent value. Now, AppleScript cannot handle 64-bit integers, so it
converts it to a real. When you later call store property list, AppleScript
sends the data as real, and my code faithfully coverts it to a real value
within the property list.

In a future version of Property List Tools I'll add a test to see if the
high 32 bits of 64bit integers are empty and downcast it to a 32bit integer
to work around this problem.

In the meantime, you can use the following code to work around the problem
(this requires my List & Record Tools scripting addition):


on coerceToInteger(rec)
-- This code coerces all the reals it finds in rec to integers.
-- This code also recurs down through any nested records it finds.
--
-- NOTE: this code *only* deals with user properties. Its possible
-- to process keyword properties as well, but that is an exercise
-- for the reader.

local keys, values

-- Pull the record apart into a list of keys and a list of values
set keys to get user property names rec
set values to get user property keys in rec

-- Iterate over the values, coercing and recurring as needed
repeat with i from 1 to length of keys
local itemClass

set itemClass to class of item i of values
if itemClass is record then
set item i of values to coerceToInteger(item i of values)
else if itemClass is real then
set item i of values to (item i of values) as integer
end if
end repeat

-- Construct and return a new record
return set user property keys in {} to values
end coerceToInteger


set vPlistFile to (path to desktop folder as string) &
"com.apple.PowerManagement.plist"
set vPlist to read property list file (vPlistFile)

-- whatever

store property list coerceToInteger(vPlist) in file vPlistFile


Cheers
-Mark

---------------------------------------------------------------------
Mark Alldritt Late Night Software Ltd.
Phone: 250-380-1725 333 Moss Street
FAX: 250-383-3204 Victoria, B.C.
WEB: http://www.latenightsw.com/ CANADA V8V-4M9
_______________________________________________
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.


  • Follow-Ups:
    • Re: Property Lists <integer> tags being writing as <real>
      • From: "John W. Baxter" <email@hidden>
    • Re: Property Lists <integer> tags being writing as <real>
      • From: SK <email@hidden>
References: 
 >Property Lists <integer> tags being writing as <real> (From: SK <email@hidden>)

  • Prev by Date: Re: advanced safari work....
  • Next by Date: Switching Processes - Previous and Next
  • Previous by thread: Re: Property Lists <integer> tags being writing as <real>
  • Next by thread: Re: Property Lists <integer> tags being writing as <real>
  • Index(es):
    • Date
    • Thread