MACSCRPT Archives

May 2006

MACSCRPT@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Philip Aker <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Fri, 19 May 2006 15:14:13 -0700
Content-Type:
text/plain
Parts/Attachments:
text/plain (72 lines)
On 2006-05-19, at 07:19:44, Duane L. Mitchell wrote:

> After upgrading to Intel Macs, iMac and MacBook, a script has  
> stopped working. What doesn't work anymore is some date math where  
> the seconds between two dates is converted to a string. The  
> resulting number is always in exponential format: 1.3528367587E+17  
> or something like that. I need a string to paste into a Word doc.

> Here's the script:

> property pReferenceDate : date "Wednesday, January 1, 2003 12:00:01  
> AM"
> set vDocNumber to ((current date) - pReferenceDate) as inches as  
> string
> display dialog "The number is: " & vDocNumber

> The "as inches as string" is my latest attempt at coercing the  
> number to a string.

> I don't have an Intel Mac but have asked someone who does to run  
> the above script. It works as it should. I'm puzzled as to why  
> these two particular Intel Macs are having this problem.

> I'd welcome any suggestions or comments. Thanks.

Maybe:

property pdate : date "Wednesday, January 1, 2003 00:00:01"
set vnum to ((current date) - pdate)
((vnum as inches) as integer) as string

But note this recent post to the AppleScript Studio list:

> On Apr 29, 2006, at 8:28 PM, Graham Jones wrote:

>> I am experiencing a very weird issue.  When I build my app on an  
>> Intel Mac, it runs perfectly on Intel Macs, but dates get  
>> corrupted when I try to run it on a PPC.  However, when I build it  
>> on a PPC, it runs perfectly on PPC machines, but the same dates  
>> get corrupted when I run it in Intel.

>> The corruption happens as follows:

>> set theDate to date "Saturday, April 29, 2006 12:00:00 AM"
>> log theDate -- "Friday, January 1, 1904 12:00:00 AM"

>> The workaround I have come up with is:
>> set theDate to current date
>> set year of theDate to 2006
>> set month of theDate to April
>> set day of theDate to 29
>> set time of theDate to 0
>> log theDate -- "Saturday, April 29, 2006 12:00:00 AM"

>> However, this workaround is clearly a hack that should not be  
>> needed.  What on earth is happening here?  Is anyone else  
>> experiencing this?


> Yeah, we discovered this just recently ourselves.  As Paul  
> surmises, the problem has to do with how dates are stored in a  
> compiled script; properties set to date values are also affected.   
> We have a fix identified, so now it's a question of getting it into  
> the next update.


> --Chris Nebel
> AppleScript and Automator Engineering

Philip Aker
philip->vcn.dot.bc.dot.ca

ATOM RSS1 RSS2