• 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: Is this yet another darn bug in 10.12.2?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is this yet another darn bug in 10.12.2?


  • Subject: Re: Is this yet another darn bug in 10.12.2?
  • From: Yvan KOENIG <email@hidden>
  • Date: Sat, 31 Dec 2016 15:37:44 +0100

All the advices already posted are meaningful but they don't solve the problem which stroke in the posted script.

(1) I added some instructions at the very beginning to be sure that the required folder was available.

(2) As the datas written in the file are a list, the read instruction must read the file as list. The required coercion was disabled.

(3) The instruction supposed to display the read datas was asking display dialog to display a list which it cant't do.

So I added my old handler “recolle“ to convert the list into a text object.
Honestly I must add that I was surprised to see that the handler coerced the date values into text object with no explicit code.
My first thought was to use : my recolle({""} & temp, linefeed) to be sure that the first item of the list was a string.

Here is the code which I was able to run with no problem.

----------------------------------
property folderName : "Mail 
Manager Folder"
property mailManagerDesktopFolderPath : ((path to desktop as text) & folderName & ":")
#property testFile : “.File Mail Size" as text
property testFile : "Store The Version IP.dat" as text


set p2d to path to desktop
tell application "System Events"
if not (exists folder mailManagerDesktopFolderPath) then make new folder at end of p2d with properties {name:folderName}
end tell
try
say 1
set p to 1
set temp to my readFile2(my testFile)
say 2
set p to 2
# You can't get display dialog to display your set of datas.
-- tell application "System Events" to display dialog temp as list # DISPLAY DIALOG CAN'T TREAT A LIST
-- tell application "System Events" to display dialog (my recolle({""} & temp, linefeed)) # FIRST ATTEMPT
tell application "System Events" to display dialog (my recolle(temp, linefeed)) # LAST VERSION
set p to 3
if (count of temp) = 6 then
say "found"
set p to 4
set StartDateOne to item 1 of temp as date
set p to 5
set tempMailCount to (item 5 of temp) + 1
set p to 6
set overallMailCount to (item 3 of temp) + 1
try
set p to 7
my writeFile8(my testFile, {StartDateOne, (current date) as date, overallMailCount, 0, tempMailCount, 0})
set p to 8
end try
else
say 10
set p to 9
my writeFile8((my testFile), {(current date) as date, (current date) as date, 0, 0, 1, 0})
say "wrote to"
end if
on error errmsg
tell application "System Events" to display dialog errmsg & " p = " & p
end try

on readFile2(theFileName)
try
set p to 10
set TheFileNameTemp to ((my mailManagerDesktopFolderPath) & theFileName)
set wholeList to read file TheFileNameTemp as list # EDITED
set p to 12
return wholeList
on error errmsg
say "error 1"
tell application "System Events" to display dialog "readFile2   p = " & p & " " & errmsg
return ""
end try
end readFile2

on writeFile8(theFileName, TheWriteItem)
try
say 100
set p to 13
set fRef to open for access file theFileName with write permission
set fRef to open for access file ((my mailManagerDesktopFolderPath) & theFileName) with write permission
set p to 14
say 101
set eof fRef to 0
set p to 15
say 102
write TheWriteItem to fRef -- < WORKS, BUT DOESN’T WRITE??????
say 103
on error errmsg
say "error 2"
tell application "System Events" to display dialog "WriteFile8  p = " & p & " " & errmsg
end try
try
close access fRef
end try
end writeFile8

on recolle(l, d) # ADDED Handler
local oTIDs, t
set {oTIDs, AppleScript's text item delimiters} to {AppleScript's text item delimiters, d}
set t to l as text
set AppleScript's text item delimiters to oTIDs
return t
end recolle
----------------------------------

Yvan KOENIG running Sierra 10.12.2 in French (VALLAURIS, France) samedi 31 décembre 2016 15:36:29


 _______________________________________________
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: Is this yet another darn bug in 10.12.2?
      • From: Yvan KOENIG <email@hidden>
References: 
 >Is this yet another darn bug in 10.12.2? (From: Brian Christmas <email@hidden>)
 >Re: Is this yet another darn bug in 10.12.2? (From: Shane Stanley <email@hidden>)
 >Re: Is this yet another darn bug in 10.12.2? (From: Shane Stanley <email@hidden>)

  • Prev by Date: Re: Is this yet another darn bug in 10.12.2?
  • Next by Date: Re: Is this yet another darn bug in 10.12.2?
  • Previous by thread: Re: Is this yet another darn bug in 10.12.2?
  • Next by thread: Re: Is this yet another darn bug in 10.12.2?
  • Index(es):
    • Date
    • Thread