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

Re: Time format


  • Subject: Re: Time format
  • From: Wayne Melrose <email@hidden>
  • Date: Sun, 18 Nov 2007 12:26:04 +0100



When I compile, I get a syntax error message:
"else" expected, but "on" found
with "on" highlighted in "on leadZero(x)".

Could you help me, please.
Thanks in advance.
This list is great for AS beginners.

BA

_________

You are trying to use a handler (function) in your script, which cannot be inside a tell block (in this case Finder)

To call on a handler you've made from within a tell block you must add the word "my" to let the tell block know that the current script owns the handler 

-- Script

try
with timeout of 1000 seconds
tell application "Finder"
set debutemps to (current date)
set time1 to (time of (current date))


--Blah, blah...


set TotalTime to (time of (current date)) - time1


-- Time formating
set t to TotalTime
set h to t div 3600
set tr to (t mod 3600)
set x to (tr div 60)
set m to my leadZero(x) -- 'of me' tried unsuccessfully
set x to (tr mod 60)
set s to my leadZero(x) -- 'of me' tried unsuccessfully
set TotalTime to m & ":" & s as string
-- End of time formating



end tell
end timeout
end try


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



-- End of script

 _______________________________________________
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

References: 
 >Time format (From: ba95 <email@hidden>)

  • Prev by Date: Time format
  • Next by Date: Re: Time format
  • Previous by thread: Time format
  • Next by thread: Re: Time format
  • Index(es):
    • Date
    • Thread