Talk About Network

Google




Programming > Applescript > Apple script fu...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 6 Topic 1483 of 1697
Post > Topic >>

Apple script functions/handers

by DaGeek <JimDaGeek@[EMAIL PROTECTED] > Jul 14, 2007 at 09:15 PM

Hey group,

I am new to OS X and applescript.  I have been programming for many 
years, though applescript seems a little weird to me because of how 
verbose and natural language like it is.

Anyway, I am trying to do something simple, I need to get the current 
date in the format: YYYY:MM:DD.

The following code gives me the name of the month instead of the number 
for the month:

set theMonth to month of theDate

So I created a simple function/handler, though I don't know what the 
heck is going on because it does not work.  I get an error that 
theMonth is not defined.

set theDate to current date
set theYear to year of theDate
set theMonth to convertMonth(month of theDate)
set theDay to day of theDate
set dateStr to theYear & ":" & theMonth & ":" & theDay

display dialog "Enter image date (YYYY:MM:DD):" default answer dateStr as
text
set theDate to text returned of result

display dialog theDate

on convertMonth(theMonth)
	if theMonth = "January" or theMonth = "Jan" then
		return "01"
	else if theMonth = "February" or theMonth = "Feb" then
		return "02"
	else if theMonth = "March" or theMonth = "Mar" then
		return "03"
	else if theMonth = "April" or theMonth = "Apr" then
		return "04"
	else if theMonth = "May" or theMonth = "May" then
		return "05"
	else if theMonth = "June" or theMonth = "Jun" then
		return "06"
	else if theMonth = "July" or theMonth = "Jul" then
		return "07"
	else if theMonth = "August" or theMonth = "Aug" then
		return "08"
	else if theMonth = "September" or theMonth = "Sep" then
		return "09"
	else if theMonth = "October" or theMonth = "Oct" then
		return "10"
	else if theMonth = "November" or theMonth = "Nov" then
		return "11"
	else if theMonth = "December" or theMonth = "Dec" then
		return "12"
	end if
end convertMonth

Thanks for any help,

Jim


--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
      ------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access
 




 6 Posts in Topic:
Apple script functions/handers
DaGeek <JimDaGeek@[EMA  2007-07-14 21:15:38 
Private Message
   2007-07-14 18:38:07 
Re: Apple script functions/handers
Sander Tekelenburg <us  2007-07-15 05:38:14 
Re: Apple script functions/handers
has <has.temp3@[EMAIL   2007-07-15 03:35:09 
Re: Apple script functions/handers
J. Stewart <cfnzrpu@[E  2007-07-15 07:32:57 
Re: Apple script functions/handers
Jolly Roger <jollyroge  2007-07-15 11:26:01 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
localhost-V2008-12-19 Mon Jan 5 19:05:05 PST 2009.