forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Completely perplexed
Goto page 1, 2  Next
 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
jwfv
Valued Contributor
Valued Contributor


Joined: 19 Mar 2002
Posts: 422
Location: Beaufort, SC

PostPosted: Thu Apr 01, 2004 2:39 pm    Post subject: Completely perplexed Reply with quote

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),2Cool)
   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 ...

Question

_________________
Joe Floyd
Back to top
View user's profile Send private message
jwfv
Valued Contributor
Valued Contributor


Joined: 19 Mar 2002
Posts: 422
Location: Beaufort, SC

PostPosted: Tue Apr 06, 2004 2:57 pm    Post subject: Full code - still perplexed Reply with quote

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),2Cool)
   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),2Cool)
   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
View user's profile Send private message
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Tue Apr 06, 2004 6:45 pm    Post subject: Reply with quote

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. Smile

_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
jwfv
Valued Contributor
Valued Contributor


Joined: 19 Mar 2002
Posts: 422
Location: Beaufort, SC

PostPosted: Tue Apr 06, 2004 6:58 pm    Post subject: Reply with quote

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
View user's profile Send private message
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Tue Apr 06, 2004 7:02 pm    Post subject: Reply with quote

Perhaps it is a bug? Smile
_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
jwfv
Valued Contributor
Valued Contributor


Joined: 19 Mar 2002
Posts: 422
Location: Beaufort, SC

PostPosted: Tue Apr 06, 2004 7:22 pm    Post subject: Reply with quote

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
View user's profile Send private message
Hooligan
VDS Developer
VDS Developer


Joined: 28 Oct 2003
Posts: 480
Location: California

PostPosted: Tue Apr 06, 2004 10:07 pm    Post subject: Reply with quote

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
View user's profile Send private message
vtol
Valued Contributor
Valued Contributor


Joined: 05 Feb 2004
Posts: 656
Location: Eastern Indiana

PostPosted: Tue Apr 06, 2004 11:29 pm    Post subject: Reply with quote

I think the @datetime is buggy, because I had trouble with it in Random and had to revert to shuffle.
Back to top
View user's profile Send private message Visit poster's website
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Tue Apr 06, 2004 11:41 pm    Post subject: Reply with quote

You might want to look at the alternative CodeScript made Smile :
http://forum.vdsworld.com/viewtopic.php?t=2100

_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
jules
Professional Member
Professional Member


Joined: 14 Sep 2001
Posts: 1043
Location: Cumbria, UK

PostPosted: Wed Apr 07, 2004 7:48 am    Post subject: Reply with quote

Hooligan's theory is right on the nail. Until a fixed version of the runtime gets released Wink 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
View user's profile Send private message Visit poster's website
jwfv
Valued Contributor
Valued Contributor


Joined: 19 Mar 2002
Posts: 422
Location: Beaufort, SC

PostPosted: Wed Apr 07, 2004 1:13 pm    Post subject: Reply with quote

Thanks for the replies, guys. I'll try the workaround. Hopefully this can be fixed sometime.
_________________
Joe Floyd
Back to top
View user's profile Send private message
Serge
Professional Member
Professional Member


Joined: 04 Mar 2002
Posts: 1480
Location: Australia

PostPosted: Wed Apr 07, 2004 3:21 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website MSN Messenger
jwfv
Valued Contributor
Valued Contributor


Joined: 19 Mar 2002
Posts: 422
Location: Beaufort, SC

PostPosted: Wed Apr 07, 2004 4:36 pm    Post subject: Reply with quote

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. Smile

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
View user's profile Send private message
jules
Professional Member
Professional Member


Joined: 14 Sep 2001
Posts: 1043
Location: Cumbria, UK

PostPosted: Wed Apr 07, 2004 4:44 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Wed Apr 07, 2004 7:13 pm    Post subject: Reply with quote

jules wrote:
weird American way of month, date and year.


Hey Razz Well then I think the UK has a weird format of date, month and year Wink

_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
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

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group