• 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: Second-Time conversion
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Second-Time conversion


  • Subject: Re: Second-Time conversion
  • From: Graff <email@hidden>
  • Date: Thu, 24 Jun 2004 12:46:47 -0400

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

on leadZero(x)
if x is less than 10 then
return "0" & x
else
return x
end if
end leadZero

-->{"John Cage"}

:-)

That's an interesting date format!

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.

- Ken
_______________________________________________
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: Second-Time conversion
      • From: Walter Ian Kaye <email@hidden>
    • Re: Second-Time conversion
      • From: Martin Orpen <email@hidden>
References: 
 >Re: Second-Time conversion (From: Martin Orpen <email@hidden>)

  • Prev by Date: QuarkXPress 6 Spread Finder
  • Next by Date: Re: Read resource forks wit applescript
  • Previous by thread: Re: Second-Time conversion
  • Next by thread: Re: Second-Time conversion
  • Index(es):
    • Date
    • Thread