• 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: Absolutely perplexed!!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Absolutely perplexed!!


  • Subject: Re: Absolutely perplexed!!
  • From: Brian Christmas <email@hidden>
  • Date: Sat, 12 Aug 2017 11:56:24 +1000

Shane, THANK YOU for your help.

I took a while for me to work out how to use your code, but your thoughts made me error trap the actual code that was writing to the .plist.

If I’ve got your code working correctly, it did not trap any errors, but mine did.

1. On first pass, being empty, my trap generated a ‘can’t get item 1 of {}’ error

2. On the second Pass, it actually correctly displayed the two array values,  ‘true’, ‘email@hidden’

3. On third pass, it errored, and the error message showed ‘true’, but then could not convert the email address to Unicode text.


4. Without any enclosing curled brackets, it errors on second pass


This code (or at leasrt the original code, worked flawlessly for 6 years, then started crashing, unedited, in the latest Sierra build, and also in High Sierra Beta (lodged feedback report).

Why are Apple stuffing up working code??????

More important, how on earth do I fix it. Nothing comes to my mind. It seems to be saving and changing the format. Is it the @ sign perhaps??? Is the Data being changed in the READ code? (which has gone uneditedd for 6 years).

I’ve also, when saving the Data, wrapped the Data in curly brackets, and tried without them. Same thing.

Regards

Santa

#  Set up Emails
try
say 100
set emailText1Array to table1ArrayController's arrangedObjects() as list
try
say (count of items of emailText1Array)
tell application "System Events" to display dialog "testing Number One " & (AddressOn of item 1 of emailText1Array & return & emailAddressOne of item 1 of emailText1Array) as text
on error errmsg number errnum
my displayError("emailText1Array Error ', " & errmsg & " error number " & errnum as text)
end try
say 101
on error errmsg
set emailText1Array to {}
my displayError("saveTheGeneralData 1 " & errmsg as text)
end try
   end tell
end tell




try


set theDictionary to ((path to desktop as text) & "Mail Manager Folder:General Data.plist") # thePPath
set thePath to ((path to desktop as text) & "errors.plist")
set {theData, theError} to current application's NSPropertyListSerialization's dataWithPropertyList:theDictionary format:(current application's NSPropertyListXMLFormat_v1_0) options:0 |error|:(reference)
if theData = missing value then error theError's localizedDescription() as text
set {theResult, theError} to theData's writeToFile:thePath options:(current application's NSDataWritingAtomic) |error|:(reference)
if not theResult as boolean then error theError's localizedDescription() as text
on error errmsg
tell application "System Events" to display dialog "testing Shane's script " & errmsg
end try



Saving the actual Data

tell application id "com.apple.systemevents"
set plistParentRecord to make new property list item with properties {kind:record} as record
set propertyListFile to make new property list file with properties {contents:plistParentRecord, name:thePPath}
#
# Actually Arrays
#
  tell property list items of propertyListFile
try
make new property list item at end with properties {kind:list, name:"emailText1Key", value:{emailText1Array}} — <<< ALWAYS FAILS HERE WHEN ACTUALLY WRITING DATA, Says ‘1’, but never ‘2’ once written.
say 1
end try



This is how I read the saved data, and reset the Array Controllers. Been OK for 6 years

set oldemailEntries to nowreadList's emailText1Key
tell table1ArrayController to removeObjects:arrangedObjects()
repeat with eachemail1 in oldemailEntries
set eachemail to eachemail1's mutableCopy()
tell table1ArrayController to addObject:eachemail
end repeat
 

On 11 Aug 2017, at 9:28 pm, Shane Stanley <email@hidden> wrote:

The most likely reason for failure is that you're passing something that can't be saved as a property list. You should use the method that returns an error, so you can find out why:

set {theData, theError} to current application's NSPropertyListSerialization's dataWithPropertyList:theDictionary |format|:(current application's NSPropertyListXMLFormat_v1_0) options:0 |error|:(reference)
if theData = missing value then error theError's localizedDescription() as text
set {theResult, theError} to theData's writeToFile:thePath options:(current application's NSDataWritingAtomic) |error|:(reference)
if not theResult as boolean then error theError's localizedDescription() as text 

Attachment: smime.p7s
Description: S/MIME cryptographic signature

 _______________________________________________
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

  • Follow-Ups:
    • Re: Absolutely perplexed!!
      • From: Shane Stanley <email@hidden>
References: 
 >Fwd: Absolutely perplexed!! (From: Brian Christmas <email@hidden>)
 >Re: Absolutely perplexed!! (From: Shane Stanley <email@hidden>)

  • Prev by Date: Re: Absolutely perplexed!!
  • Next by Date: Re: Absolutely perplexed!!
  • Previous by thread: Re: Absolutely perplexed!!
  • Next by thread: Re: Absolutely perplexed!!
  • Index(es):
    • Date
    • Thread