Page 1 of 1

Holiday Smarts, U.S.

Posted: Fri Jul 04, 2003 10:12 pm
by LJ
The Purebasic HELP file on FormatDate reads:

Code: Select all

FormatDate()

Syntax

Text$ = FormatDate(Mask$, Date) 
Description

Returns a string representation of the Date, according to the specified Mask$. The Mask$ is a string which tells how the date should be formatted. The Mask$ accepts several reserved tokens: 
  %yyyy: Will be replaced by the year value, on 4 digits. 
  %yy: Will be replaced by the year value, on 2 digits. 
  %mm: Will be replaced by the month value, on 2 digits. 
  %dd: Will be replaced by the day value, on 2 digits.
How many times have you used a program that popped up a nice holiday message? You can very easily add this functionality to your program. Remember, this works only for hard coded date holidays (holidays that are on a specific date as opposed to "third Thursday" of the month).

Code: Select all

Date$ = FormatDate("%mm/%dd", Date())

If date$="01/01"
MessageRequester("Title", "Happy New Year!", 0)
EndIf

If date$="02/14"
MessageRequester("Title", "Happy Valentines Day!", 0)
EndIf

If date$="03/17"
MessageRequester("Title", "Happy St. Patricks Day!", 0)
EndIf

If date$="07/04"
MessageRequester("Title", "Happy 4th of July!", 0)
EndIf

If date$="11/11"
MessageRequester("Title", "Happy Veterans Day", 0)
EndIf

If date$="12/25"
MessageRequester("Title", "Merry Christmas", 0)
EndIf


Posted: Fri Jul 04, 2003 10:52 pm
by GPI
why "Left(date$,5)"?

date$ should be enought.

Yes

Posted: Sat Jul 05, 2003 6:52 am
by LJ
Code corrected.