Re: Second-Time conversion
Re: Second-Time conversion
- Subject: Re: Second-Time conversion
- From: Walter Ian Kaye <email@hidden>
- Date: Thu, 24 Jun 2004 15:13:35 -0700
At 12:46p -0400 06/24/2004, Graff didst inscribe upon an electronic papyrus:
On Jun 24, 2004, at 11:47 AM, Martin Orpen wrote:
set t to 273
set h to t div 3600
set tr to (t mod 3600)
set x to (tr div 60)
set m to leadZero(x)
set x to (tr mod 60)
set s to leadZero(x)
h & ":" & m & ":" & s as string
One thing you might want to change is the second return in the
leadZero handler. The way it is now you either return a string or a
number, depending on whether or not the number is less than 10. If
you change the second return to this then it will always return a
string:
return "" & x
What you have right now works simply because you later coerce the
returned value to a string, so it doesn't matter if it is a string
or a number. If you put the coercion into the handler in the first
place you cut down the chances of a bug down the road.
Or since it's starting with the 'h', just make the h a string and the
rest will automatically coerce likewise.
At 06:28p +0100 06/24/2004, Martin Orpen didst inscribe upon an
electronic papyrus:
Recently I've been posting snippets to our site and have come to realise how
badly the scripts perform in the *real world*.
Is there any easy way of ironing out problems like this, or is it just a
case of trial and error and maintaining an extensive (and expensive)
collection of hardware and software to test stuff out on?
Well that rather depends on what stuff "like this" is.
Of course Apple does have a lab in Cupertino where developers can go
to test stuff out on, but for 99% of developers that's just a tad
inconvenient. ;)
Does using something like Script Debugger make this process easier I wonder?
SD makes a lot of things easier, but of course a tool's only as good
as the person using it. :-) I mean, you have to be able to
understand what SD can show you in order to get the benefit. I find
viewing the AEBuild format of a value to be the most helpful thing of
all.
-boo
_______________________________________________
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.