I am quite new to AS. What I want is to ask the user for inputing a date. Then, I want to compare the date with the current date. In the following piece of code, it seems that mydate is not defined. Can anybody help ?
tell application “Microsoft Excel”
activate
set thedate to display dialog “enter date” default button “OK” default answer “”
set answer to text returned of thedate
set mydate to date answer
set current_date to current date
if current_date > mydate then
display dialog current_date
else
display dialog mydate
end if
the format of the entered date must be one of the specified date formats in System Preferences > International > Formats
Here are some lines of code to check the format
repeat
set thedate to display dialog "enter date" default button "OK" default answer ""
set answer to text returned of thedate
try
set mydate to date answer
mydate
exit repeat
on error
tell (current date) to set timeString to short date string & space & time string
display dialog "enter date with format " & return & timeString
end try
end repeat
set current_date to current date
if current_date > mydate then
display dialog current_date as text
else
display dialog mydate
end if
Sorry to say that it does not work. I run the script and I am asked to input a date with this format dd/mm/aa hh:mm:ss. And it asks it again an again which means that there is always an error. Don’t you think that the problem still comes from the expression