Validating Custom Dates in my own game

Please use this Board for QBasic related requests ( file research, programming, etc.)

Moderators:Administrator, Global Moderator

Post Reply
worchyld
Newbie
Posts:2
Joined:Fri Aug 15, 2003 3:24 pm
Validating Custom Dates in my own game

Post by worchyld » Fri Aug 15, 2003 3:33 pm

In my game I want to use

type curGame
    day as integer
    week as integer
    month as integer
    year as integer
end type

You play each 'day' and the day is incremented at the end of each day (thus incrementing the week, month, etc).

Now how do I validate my day/week/month/year to ensure that the date I've displayed is a valid one?

For example it should detect where there are 30/31 days in a month or whether its a leap-year?

Is there a way of validating the date perhaps against a calendar?

Thanks.

User avatar
frankiebaby
Global Moderator
Posts:95
Joined:Tue Apr 30, 2002 1:38 am
Location:Pennsylvania
Contact:

Re: Validating Custom Dates in my own game

Post by frankiebaby » Sat Aug 16, 2003 9:09 am

well, if u try to use the date$ statement in Qbasic and enter an invalid date, it will give u an illegal function call error. an error trapping routine could be used, but the error is rather generic. (u may already have other error trapping routines) A look-look up array of 1 to 12 could be used to store the max number of days in each month, and I think (when's the next leap year???) lets say 2003 was a leap year if ya do IF thisyear + 1 MOD 4 = 0 THEN, u would get an answer of whether or not it is a leap year right? i think. well, u would change the 1 to the right offset to make it work :) if it is a leap year, u can figure out how to act on that. good luck! is it an RPG?

worchyld
Newbie
Posts:2
Joined:Fri Aug 15, 2003 3:24 pm

Re: Validating Custom Dates in my own game

Post by worchyld » Wed Aug 20, 2003 6:12 pm

Thanks a lot for all your help.

I downloaded quite a few calendar scripts - I got one of them to work pretty well (with Leap Year functions, etc) - all I do is keep a storage of the day, month and year (I ditched the week idea) and call the appropriate function or test it against the calendar's maximum values.

It seems to be working alright now.

Again, thank you again for all your help

Post Reply