Search content:

 

Personal Menu
Username:
Password:
Save password

Become a member

Forgot Password?

 

Don't miss these
Password Field
HJ Install
keyboard input control
Director 6 Demystified
MostFramesScript
Open URL
Cut Behavior (Ctrl + X)
Star Parent Script
Change Line Direction of a Shape Sprite
Control Buttons for DirectMedia Sprite
MediaMacros Xtras Mall
 

 

 

Behavior Number of Days in a Month

Added on 12/12/2005

 

Compatibilities:
D8 D8_5 D9 PC Script

This item has not yet been rated

Author: Chunick (website)

This should be placed in a moviescript. To use place script in a movieScript and call from anywhere, such as the message window. You can either pass the month and year or just the month... which will assume the current year. One big thing to note is that the code is much more than you would normally need to do the job. Here's the code you would normally need: on daysInMonth(theMonth, theYear) return date(theYear, theMonth + 1, 1) - date(theYear, theMonth, 1) end However, this is a bit inflexible... let's say I don't want to provide the year or maybe I want to provide the name of the month rather than the month number... or even the abbreviated name of the month... all of that is possible with the first custom handler. All that being said, here are some of the parameters that can be passed: -- from the message window if the code is placed in a moviescript put daysInMonth(12, 2005) -- 31 put daysInMonth(11) -- 30 put daysInMonth("February") -- 28 put daysInMonth("feb") -- 28 put daysInMonth("Feb") -- 28 Actually, this behavior is a good example of how to use the findPosNear() function for lists as well as allowing for different data types and numbers of parameters to be passed to a function.

on daysInMonth(theMonth, theYear)
months = [#January: 1, #February: 2, #March: 3, #April: 4, #May: 5, #June: 6, #July: 7, #August: 8, #September: 9, #October: 10, #November: 11, #December: 12]
months.sort()
if ilk(theMonth) = #string then theMonth = months[months.findPosNear(symbol(theMonth))]
if theYear = 0 then theYear = the systemDate.year
return date(theYear, theMonth + 1, 1) - date(theYear, theMonth, 1)
end

 


Upload Provided by ABCUpload ASP

Contact

MMI
22 West Court Sq
Suite 2C
Newnan, GA 30263
USA

Fax - (206) 339-5833

Send e-mail