dateitems help
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Posts: 78
- Joined: Fri Oct 03, 2008 10:13 am
forgot this
altAnswerDate
This is a free wrapper for Shao Sean'sfine calendarWidget which can be called simply like an answer dialog box. (Thanks again Shao for a great tool!!!!)
To use this stack, make the stack "calendarWidget100" a substack of your main stack. Then when you need to prompt the user for a date, you can put the following into a button script (like the one below):
on mouseUp
put "2006" into tYear
put "8" into tMonth
put "12" into tDay
start using stack "calendarWidget100"
get altAnswerDate(tYear,tMonth,tDay)
stop using stack "calendarWidget100"
if it is empty then exit mouseUp
put it into fld 1
end mouseUp
Note: If you like, you can insert the start using and stop using statements in your startup routine. This will keep the stack loaded in memory. Also, note you can force the calendar to open to a specific date. If you want it to open to today's date, then put "" into tYear, tMonth and tDay.
This is a free wrapper for Shao Sean'sfine calendarWidget which can be called simply like an answer dialog box. (Thanks again Shao for a great tool!!!!)
To use this stack, make the stack "calendarWidget100" a substack of your main stack. Then when you need to prompt the user for a date, you can put the following into a button script (like the one below):
on mouseUp
put "2006" into tYear
put "8" into tMonth
put "12" into tDay
start using stack "calendarWidget100"
get altAnswerDate(tYear,tMonth,tDay)
stop using stack "calendarWidget100"
if it is empty then exit mouseUp
put it into fld 1
end mouseUp
Note: If you like, you can insert the start using and stop using statements in your startup routine. This will keep the stack loaded in memory. Also, note you can force the calendar to open to a specific date. If you want it to open to today's date, then put "" into tYear, tMonth and tDay.
-
- Posts: 78
- Joined: Fri Oct 03, 2008 10:13 am
still no luck
I've been looking at the output of the altAnswerDate picker and it doesn't seem to be in the regular dateItems format i.e. it only has the: the year, the month number, day of the month and the numeric day of the week , whereas the dateItems format is supposed to be:
* the year
* the month number
* the day of the month
* the hour in 24-hour time
* the minute
* the second
* the numeric day of the week where Sunday is day 1, Monday is day 2, and so forth,
Since this output has only four comma delimited items instead of the usual seven and that they're not in the usual order, is it possible that rev is trying to convert the wrong items and does anyone know if that would make a difference to revs ability to convert it to another date format?.
* the year
* the month number
* the day of the month
* the hour in 24-hour time
* the minute
* the second
* the numeric day of the week where Sunday is day 1, Monday is day 2, and so forth,
Since this output has only four comma delimited items instead of the usual seven and that they're not in the usual order, is it possible that rev is trying to convert the wrong items and does anyone know if that would make a difference to revs ability to convert it to another date format?.
AHA!
Yep, if "the dateitems" are not in the correct/required format, then "convert" will of course fail!
But you could workaround it by adding the missing items manually!
Like 0 for the hour, 0 for the minutes and seconds:
...
put altAnswerDate(tYear,tMonth,tDay) into my_date
put item -1 of my_date into day_of_week
delete item -1 of my_date
put ",0,0,0," & day_of_week after my_date
## NOW my_date is in the correct"dateitems" format
## and you can do whatever you wanted with it
...
Hope that helps.
Best
Klaus
Yep, if "the dateitems" are not in the correct/required format, then "convert" will of course fail!
But you could workaround it by adding the missing items manually!
Like 0 for the hour, 0 for the minutes and seconds:
...
put altAnswerDate(tYear,tMonth,tDay) into my_date
put item -1 of my_date into day_of_week
delete item -1 of my_date
put ",0,0,0," & day_of_week after my_date
## NOW my_date is in the correct"dateitems" format
## and you can do whatever you wanted with it
...
Hope that helps.
Best
Klaus
-
- Posts: 78
- Joined: Fri Oct 03, 2008 10:13 am
Brilliant!!!
Klaus, it works a treat, it didn't work with the altAnswerDate var although i may have been missing something, so i tried the following code and it worked perfectly:
put "" into tYear
put "" into tMonth
put "" into tDay
start using stack "calendarWidget100"
get altAnswerDate(tYear,tMonth,tDay)
stop using stack "calendarWidget100"
if it is empty then exit mouseUp
put it into my_date
put item -1 of my_date into day_of_week
delete item -1 of my_date
put ",0,0,0," & day_of_week after my_date
put my_date into fld "Date3"
add 3 to item 1 of my_date
put my_date into fld "Date4"
convert fld "Date3" from dateItems to system date
convert fld "Date4" from dateItems to system date
So thanks Klaus for your expert help and thanks also to Mark and to BvG and everyone who contributed to this thread,
Cheers!!!
put "" into tYear
put "" into tMonth
put "" into tDay
start using stack "calendarWidget100"
get altAnswerDate(tYear,tMonth,tDay)
stop using stack "calendarWidget100"
if it is empty then exit mouseUp
put it into my_date
put item -1 of my_date into day_of_week
delete item -1 of my_date
put ",0,0,0," & day_of_week after my_date
put my_date into fld "Date3"
add 3 to item 1 of my_date
put my_date into fld "Date4"
convert fld "Date3" from dateItems to system date
convert fld "Date4" from dateItems to system date
So thanks Klaus for your expert help and thanks also to Mark and to BvG and everyone who contributed to this thread,
Cheers!!!
DateItems
I'm sorry I didn't see your post sooner - I also ran into the same problem earlier this year and eventually sorted it out by reorganising the result like this:
put "" into tYear
put "" into tMonth
put "" into tDay
start using stack "calendarWidget100"
get altAnswerDate()
stop using stack "calendarWidget100"
if it is empty then exit mouseUp
put it into myT
put item 1 of myT into t4
put item 3 of myT & "/" before line 1 of t4
put item 2 of myT & "/" before line 1 of t4
convert t4 to long english date
Best
Jim
put "" into tYear
put "" into tMonth
put "" into tDay
start using stack "calendarWidget100"
get altAnswerDate()
stop using stack "calendarWidget100"
if it is empty then exit mouseUp
put it into myT
put item 1 of myT into t4
put item 3 of myT & "/" before line 1 of t4
put item 2 of myT & "/" before line 1 of t4
convert t4 to long english date
Best
Jim
-
- Posts: 78
- Joined: Fri Oct 03, 2008 10:13 am
dateItems
Hi, thanks for the reply, i got the dateItems problem with my stack sorted out a while ago, but the date picker didn't work with my stack when i ran it in the rev player, i ran it both with my stack and then on its own and got the same problem, so i decided to use the date picker stack by BvG instead which serves the same purpose and i use it as a group within my stack rather than as a substack and it fits the look of my stack better than the altAnswerDate stack,
But thanks for your reply.
Regards
Wee Wullie
But thanks for your reply.
Regards
Wee Wullie
Re: dateitems help
'DatePicker for LiveCode' has been released and is available from the LiveCode store. It may provide a ready-made solution for you, unless you need to roll your own.
Hugh Senior
FLCo
Hugh Senior
FLCo
The Flexible Learning Company
• ChartMaker: www.FlexibleLearning.com/chartmaker
• ControlManager: www.FlexibleLearning.com/controlmanager
• The Scripter's Scrapbook: www.FlexibleLearning.com/ssbk
• DatePicker: www.FlexibleLearning.com/datepicker
• ChartMaker: www.FlexibleLearning.com/chartmaker
• ControlManager: www.FlexibleLearning.com/controlmanager
• The Scripter's Scrapbook: www.FlexibleLearning.com/ssbk
• DatePicker: www.FlexibleLearning.com/datepicker