returning a weekday from user input?


I’m pretty new to applescript and am trying to ask a user to return a weekday from a list. I’ve tried several ways with no luck, the script is below - can anyone show me how to do this? Also can I declare a “theDate” variable without setting it?

set theDate to current date
choose from list {¬
Monday, ¬
Tuesday, ¬
Wednesday, ¬
Thursday, ¬
Friday, ¬
Saturday, ¬
Sunday} ¬
with prompt “Select Day of Recording”
set weekday of theDate to result



Are you talking about something like:

set the_list to {“Monday”, “Tuesday”, “Wdenesday”, “Thursday”, “Friday”, “Saturday”, “Sunday”}
set the_result to choose from list the_list
display dialog the_result

this script was automatically tagged for
color coded syntax by Script to Markup Code
written by Jonathan Nathan


I don’t think so. I’m trying to construct a variable of class type date from user input. So, I’m asking them to enter weekday, day, month, year and then trying to construct a date from that. As I then want to do some arithmetic on the date, I can’t deal with the input as strings unless I write some subroutines to handle dates represented as strings. My understanding is that Applescript provides a date class with subclasses of weekday, day, month and year. The script I gave provided options as types of the weekday class (like an enum in C i guess) rather than using “Monday”, which I guess would be taken as a string. However when I try to set the weekday of my date variable from the result I get an error.

I guess what I’m looking for is a typecast style operation that will allow the result to be returned as a weekday type?

I’m guessing that the solution given deals with the days of the weeks as a list of strings?



It’s easier to let AppleScript come up with the weekday from a given date. To allow the user to input a date, try this routine:


[This script was automatically tagged for color coded syntax by Script to Markup Code]

Thanks! That’s the one, I’ve used the following syntax lifted from your example:

set RecEvent to date (RecMonth & space & RecDate & ", " & RecYear & space & RecHour & “:” & RecMin & “:00”)

That’s helped me through many an hour of frustration! :lol: