| View previous topic :: View next topic |
| Author |
Message |
jwfv Valued Contributor

Joined: 19 Mar 2002 Posts: 422 Location: Beaufort, SC
|
Posted: Thu Apr 01, 2004 2:39 pm Post subject: Completely perplexed |
|
|
I can not figure this out. I have a program that has a popup calendar dialog, using the Calendar element named Gencal. When that dialog is active, if the user presses the "monthforward" button, it adds 31 days to the current date and sets the calendar element with the new date. UNLESS the current date has a day value over 27, in which case it adds 28 days.
I get an error (error 23) when I try to go forward on any day over 27. If it is below 27, it works fine.
Why won't the following code work?
| Code: | %%tmpev = @event()
if @equal(%%tmpev,monthrightbutton)
parse "%%tmp1;%%tmp2;%%tmp3", @dlgtext(gencal)
if @greater(%%tmp2,27)
rem The statement below does NOT work.
dialog set, gencal, @datetime(mm/dd/yy,@fadd(@datetime(,%%tmp1/%%tmp2/%%tmp3),2 )
else
rem The statement below DOES work.
dialog set, gencal, @datetime(mm/dd/yy,@fadd(@datetime(,%%tmp1/%%tmp2/%%tmp3),31))
end
parse "%%tmp1;%%tmp2;%%tmp3", @dlgtext(gencal)
dialog set, monthyear, @trim(@datetime(mmmm yyyy, %%tmp1/%%tmp2/%%tmp3))
end
|
If I replace the "28" in the first dialog set command with a "31" it works fine.
Also, I know that error 23 is "dialog element name not valid" but it is clearly the same thing I am calling it in the other dialog set command that works ...
 _________________ Joe Floyd |
|
| Back to top |
|
 |
jwfv Valued Contributor

Joined: 19 Mar 2002 Posts: 422 Location: Beaufort, SC
|
Posted: Tue Apr 06, 2004 2:57 pm Post subject: Full code - still perplexed |
|
|
Here is a complete example that will demonstrate my problem. Any help is greatly appreciated!
This program displays a calendar with "month forward" and "month backward" days. It works fine unless you "forward" or "back" from the 31st of the month. Try it and you'll see. I can't figure out where in the world the error is coming from.
| Code: |
DIALOG CREATE,Set Date,100,100,246,191
DIALOG ADD,STYLE,groupstyle,,,,WHITE,
DIALOG ADD,STYLE,titlestyle,Arial,12,C,,BLUE
REM *** Modified by Dialog Designer on 6/26/2003 - 22:22 ***
DIALOG ADD,GROUP,titlegroup,3,38,174,30,,,groupstyle
DIALOG ADD,CALENDAR,gencal,36,32,185,108,%%retdate,,click
DIALOG ADD,BUTTON,okdate,156,52,64,24,OK
DIALOG ADD,BUTTON,cancdate,156,144,64,24,Cancel
DIALOG ADD,text,monthyear,8,40,170,20,monthyear,,titlestyle
DIALOG ADD,BUTTON,monthright,8,214,20,20,>
DIALOG ADD,BUTTON,monthleft,8,16,20,20,<
DIALOG SHOW
parse "%%tmp1;%%tmp2;%%tmp3", @dlgtext(gencal)
dialog set, monthyear, @trim(@datetime(mmmm yyyy, %%tmp1/%%tmp2/%%tmp3))
:datewait
wait event
%%tmpev = @event()
if @equal(%%tmpev,monthrightbutton)
parse "%%tmp1;%%tmp2;%%tmp3", @dlgtext(gencal)
if @greater(%%tmp2,27)
dialog set, gencal, @datetime(mm/dd/yy,@fadd(@datetime(,%%tmp1/%%tmp2/%%tmp3),2 )
else
dialog set, gencal, @datetime(mm/dd/yy,@fadd(@datetime(,%%tmp1/%%tmp2/%%tmp3),31))
end
parse "%%tmp1;%%tmp2;%%tmp3", @dlgtext(gencal)
dialog set, monthyear, @trim(@datetime(mmmm yyyy, %%tmp1/%%tmp2/%%tmp3))
end
if @equal(%%tmpev,monthleftbutton)
parse "%%tmp1;%%tmp2;%%tmp3", @dlgtext(gencal)
if @greater(%%tmp2,27)
dialog set, gencal, @datetime(mm/dd/yy,@fsub(@datetime(,%%tmp1/%%tmp2/%%tmp3),31))
else
dialog set, gencal, @datetime(mm/dd/yy,@fsub(@datetime(,%%tmp1/%%tmp2/%%tmp3),2 )
end
parse "%%tmp1;%%tmp2;%%tmp3", @dlgtext(gencal)
dialog set, monthyear, @trim(@datetime(mmmm yyyy, %%tmp1/%%tmp2/%%tmp3))
end
if @equal(%%tmpev,gencalclick)
parse "%%tmp1;%%tmp2;%%tmp3", @dlgtext(gencal)
dialog set, monthyear, @trim(@datetime(mmmm yyyy, %%tmp1/%%tmp2/%%tmp3))
end
if @equal(%%tmpev,cancdatebutton)
exit
end
if @equal(%%tmpev,CLOSE)
exit
end
if @equal(%%tmpev,okdatebutton)
exit
end
goto datewait
exit
|
Thanks, anyone. _________________ Joe Floyd |
|
| Back to top |
|
 |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
Posted: Tue Apr 06, 2004 6:45 pm Post subject: |
|
|
It seems to happen only when you have selected the 31st and there is not
a 31st day in the next or previous month. Therefore maybe you could
check what months have 31 days, and if not, set it to the last date of that
month.  _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
| Back to top |
|
 |
jwfv Valued Contributor

Joined: 19 Mar 2002 Posts: 422 Location: Beaufort, SC
|
Posted: Tue Apr 06, 2004 6:58 pm Post subject: |
|
|
Thanks FF for checking it out.
I can't for the life of me figure out what the problem is, though.
If given the starting date of 5/29, the "next month" button moves it to 6/26 (like it should.)
If given the starting date of 5/30, the button moves it to 6/27 (again, correct.)
If given the starting date of 5/31, the button gives an error message saying "dialog element name not valid."
It makes no sense to me. _________________ Joe Floyd |
|
| Back to top |
|
 |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
Posted: Tue Apr 06, 2004 7:02 pm Post subject: |
|
|
Perhaps it is a bug?  _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
| Back to top |
|
 |
jwfv Valued Contributor

Joined: 19 Mar 2002 Posts: 422 Location: Beaufort, SC
|
Posted: Tue Apr 06, 2004 7:22 pm Post subject: |
|
|
That's what I thought - but I thought maybe I was overlooking something very simple. I'm just trying to add 28 days to a @datetime() value with a "day" value of 31. And it seems to blow up my program, returning an inaccurate error. Unless someone else sees something I don't ... ? _________________ Joe Floyd |
|
| Back to top |
|
 |
Hooligan VDS Developer


Joined: 28 Oct 2003 Posts: 480 Location: California
|
Posted: Tue Apr 06, 2004 10:07 pm Post subject: |
|
|
OK... I played with it a little, and yes, I suspect there is a bug... But I think there is also a workaround... I haven't time right now to test it, but maybe you can... My theory:
When the calender progresses or regresses a month, the internal code changes the month first (without testing the day). If the day is invalid for that month, than it chokes. If my theory holds, then you can regress the day by, say 7 days, set the dialog element regress/progress the month, set the dialog element, progress the day by your 7 days, and set the dialog element for the final time.
Good luck...
Hooligan _________________ Hooligan
Why be normal? |
|
| Back to top |
|
 |
vtol Valued Contributor


Joined: 05 Feb 2004 Posts: 656 Location: Eastern Indiana
|
Posted: Tue Apr 06, 2004 11:29 pm Post subject: |
|
|
| I think the @datetime is buggy, because I had trouble with it in Random and had to revert to shuffle. |
|
| Back to top |
|
 |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
|
| Back to top |
|
 |
jules Professional Member


Joined: 14 Sep 2001 Posts: 1043 Location: Cumbria, UK
|
Posted: Wed Apr 07, 2004 7:48 am Post subject: |
|
|
Hooligan's theory is right on the nail. Until a fixed version of the runtime gets released his proposed workaround should do the trick (it's exactly what the fixed runtime would do internally.)
The Calendar element was added to VDS by SADE in VDS 4, and this bug has presumably been there since then. _________________ The Tech Pro
www.tech-pro.net |
|
| Back to top |
|
 |
jwfv Valued Contributor

Joined: 19 Mar 2002 Posts: 422 Location: Beaufort, SC
|
Posted: Wed Apr 07, 2004 1:13 pm Post subject: |
|
|
Thanks for the replies, guys. I'll try the workaround. Hopefully this can be fixed sometime. _________________ Joe Floyd |
|
| Back to top |
|
 |
Serge Professional Member


Joined: 04 Mar 2002 Posts: 1480 Location: Australia
|
Posted: Wed Apr 07, 2004 3:21 pm Post subject: |
|
|
i looked at your code on my laptop running windows 98se + vds 5 and the weirdest thing happened...when i click on the day of the displayed calendar, it takes me to the equivalent month eg. if i click on 2, then it takes me to feb, if i click on 7 then it takes me to july...and all the days are the same...the 4th (and the day i did this was actually the 7th)
i could not reproduce the error on my desktop running vds 5 and windows 98se...weird!!!
anyone else found that problem?
serge _________________
|
|
| Back to top |
|
 |
jwfv Valued Contributor

Joined: 19 Mar 2002 Posts: 422 Location: Beaufort, SC
|
Posted: Wed Apr 07, 2004 4:36 pm Post subject: |
|
|
I have not seen that, but all my machines I test on are win XP. I would be interested to know if anyone has seen this problem, before a user reports it.
I tried the workaround and it seems to work fine - I take 4 days away, then do the normal date addition or subtraction. _________________ Joe Floyd |
|
| Back to top |
|
 |
jules Professional Member


Joined: 14 Sep 2001 Posts: 1043 Location: Cumbria, UK
|
Posted: Wed Apr 07, 2004 4:44 pm Post subject: |
|
|
I found something like that as well. The code has been written assuming the date will be expressed that weird American way of month, date and year. But in fact, VDS takes the date format from the local settings, unless you use an option to override it. _________________ The Tech Pro
www.tech-pro.net |
|
| Back to top |
|
 |
FreezingFire Admin Team

Joined: 23 Jun 2002 Posts: 3508
|
Posted: Wed Apr 07, 2004 7:13 pm Post subject: |
|
|
| jules wrote: | | weird American way of month, date and year. |
Hey Well then I think the UK has a weird format of date, month and year  _________________ FreezingFire
VDSWORLD.com
Site Admin Team |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|