Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
wee wullie
- Posts: 78
- Joined: Fri Oct 03, 2008 10:13 am
Post
by wee wullie » Thu Oct 09, 2008 9:30 am
I'm trying to convert the output from shao sean's altAnswerDate date picker, the output is in dateitems format, however, it wont convert to system date, i'm trying to add the picked date to Field1 then add 3 years to the date and insert into Field2, this is my button code:
Code: Select all
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 fld "Field1"
add 3 to item 1 of it
convert it to system date
put it into fld "Field2"
Anybody know what i'm doing wrong?
-
Mark
- Livecode Opensource Backer

- Posts: 5150
- Joined: Thu Feb 23, 2006 9:24 pm
-
Contact:
Post
by Mark » Thu Oct 09, 2008 11:27 am
Hi Wee,
The new date may not exist. Check the result after the convert command.
Code: Select all
convert myDate to system date
put the result into rslt
if rslt is not empty then
beep
answer error rslt
end if
When your scripts get more complex, it may be helpful to avoid using the it variable as much as possible.
Best,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
-
wee wullie
- Posts: 78
- Joined: Fri Oct 03, 2008 10:13 am
Post
by wee wullie » Thu Oct 09, 2008 11:34 pm
Thanks mark, i couldn't get the code to work, when i used the myDate var it came back with a invalid date error,
the button is doing the calculation i.e. adding 3 years to the second field but both are showing dateItems format,
By the way, i'm sure your code is fine, i'm just fairly new to rev.
Thanks for your help!
-
Mark
- Livecode Opensource Backer

- Posts: 5150
- Joined: Thu Feb 23, 2006 9:24 pm
-
Contact:
Post
by Mark » Thu Oct 09, 2008 11:41 pm
Hi Wee,
If the date is invalid, it probably doesn't exist :-)
What about converting your date to seconds, adding 3*365*24*60*60 seconds to your date and converting that back to a date? Even if not exactly accurate, it should give you a valid date.
Best,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
-
wee wullie
- Posts: 78
- Joined: Fri Oct 03, 2008 10:13 am
Post
by wee wullie » Fri Oct 10, 2008 12:43 am
I was going to give that a try Mark, but i still need the date picker in my stack, so the output of the altDate picker would still need to be converted from its current dateItems format.
-
Mark
- Livecode Opensource Backer

- Posts: 5150
- Joined: Thu Feb 23, 2006 9:24 pm
-
Contact:
Post
by Mark » Fri Oct 10, 2008 11:47 am
Wee,
What I mean is: first convert the dateItems to seconds and do all the calculations with seconds rather than dateItems.
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
-
Klaus
- Posts: 14198
- Joined: Sat Apr 08, 2006 8:41 am
-
Contact:
Post
by Klaus » Fri Oct 10, 2008 5:20 pm
Hi wee wullie,
since I regularly use "the dateitems" to calcualte dates and never had problems, I'd love to see what IT contains after this line:
Code: Select all
...
get altAnswerDate(tYear,tMonth,tDay)
...
And what do you get instead as the result of this script?
An error or just a wrong date?
Could you post this please?
And you could also try these lines, additions in bold:
Code: Select all
put "" into tYear
put "" into tMonth
put "" into tDay
start using stack "calendarWidget100"
get altAnswerDate(tYear,tMonth,tDay)
## IT will change its content when you least expect IT :-)
PUT IT INTO date2calculate
stop using stack "calendarWidget100"
if date2calculate is empty then exit mouseUp
put date2calculate into fld "Field1"
# Maybe "the itemdelimiter" has changed unnoticed?
SET ITEMDEL TO COMMA
add 3 to item 1 of date2calculate
convert date2calculate FROM DATEITEMS to system date
put date2calculate into fld "Field2"
Best
Klaus
-
wee wullie
- Posts: 78
- Joined: Fri Oct 03, 2008 10:13 am
Post
by wee wullie » Sun Oct 12, 2008 10:59 am
Hi Mark, i tried converting it to seconds but it runs into an error:
compiling at 10:39:27 AM
Type Chunk: can't create a variable with that name (explicitVariables?)
Object Pick Date
Line put "" into tYear
Hint tYear
This error comes up whatever type of changes i try to make to the date picker button script even when i revert it back, i'll download the datepicker again and try converting it to seconds and post how i get on.
-
BvG
- VIP Livecode Opensource Backer

- Posts: 1239
- Joined: Sat Apr 08, 2006 1:10 pm
-
Contact:
Post
by BvG » Sun Oct 12, 2008 11:29 am
I had a similar problem with a stack in use once, the code would just not work after an error in the script that referenced stuff in the stack in use was thrown. All error reporting ceased to be useful, always pointing to that first error, unless I'd rectify every single error in my script. Then it would work until another error was introduced, and so one.
That was, until I saw, after a few days, that I had somehow set the lockMessages to true. So... can you check that its not true?
Various teststacks and stuff:
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
-
wee wullie
- Posts: 78
- Joined: Fri Oct 03, 2008 10:13 am
Post
by wee wullie » Sun Oct 12, 2008 12:53 pm
Hi BvG, I set the lockMessages to false and that got rid the errors , thank you.
I looked at the date picker script using the script reporter in the utilities section of revonline, it converts from dateitems to seconds then back to dateitems, it looks rather complicated to me.
-
wee wullie
- Posts: 78
- Joined: Fri Oct 03, 2008 10:13 am
Post
by wee wullie » Sun Oct 12, 2008 1:09 pm
Hi Klaus, I tried the code you posted and it produces the same result i.e.
the picked date is updated as is the calculated date but they are still displayed in dateItems format.
-
Mark
- Livecode Opensource Backer

- Posts: 5150
- Joined: Thu Feb 23, 2006 9:24 pm
-
Contact:
Post
by Mark » Sun Oct 12, 2008 2:53 pm
Wee,
What do you get back from
?!
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
-
wee wullie
- Posts: 78
- Joined: Fri Oct 03, 2008 10:13 am
Post
by wee wullie » Sun Oct 12, 2008 4:06 pm
executing at 4:05:32 PM
Type Function: error in function handler
Object Button
Line get altAnswerDate(tYear,tMonth,tDay)
Hint altAnswerDate
-
Mark
- Livecode Opensource Backer

- Posts: 5150
- Joined: Thu Feb 23, 2006 9:24 pm
-
Contact:
Post
by Mark » Sun Oct 12, 2008 5:46 pm
Wee,
Can you try something along the lines of this:
Code: Select all
start using stack "calendarWidget100"
put the result into rslt
if rslt is not empty then
beep
answer rslt
else
get altAnswerDate(tYear,tMonth,tDay)
-- rest of script
end if
and let me know whether you get an answer dialog.
Could you also post the documentation regarding the altAnswerDate function?
Best,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
-
wee wullie
- Posts: 78
- Joined: Fri Oct 03, 2008 10:13 am
Post
by wee wullie » Sun Oct 12, 2008 6:28 pm
Mark, when i used the code i got the error:
executing at 6:17:26 PM
Type Operators mod: error in left operand
Object calendarWidget
Line else if ((the uYear of me MOD 400 = 0) OR ((the uYear of me MOD 100 <> 0) AND (the uYear of me MOD 4 = 0))) then
Hint group id 1021 of card id 1002 of stack "calendarWidget100" of stack "C:/Documents and Settings/admin/My Documents/calendarWidget100.rev"