User:Mitrebox
This page is a self page. It is the base for a project I am attempting.
Please Read
This page is part of an assignment I'm doing for a class.
- If you view this page please sign my talk page in the VIEW area.
- If you edit this page please sign my talk page in the EDIT area.
-Thankyou --Mitrebox 14:53, 8 Apr 2005 (UTC)
Wiki Code Functions
A wiki onto which function sourcecode would be placed and avliable for viewing and editing by others.
Purpose
- Provide others with cut and paste functions
- Provide others with functions they can copy and customized for their own needs
- Provide examples of code to others for them to build their programs
- Create a repository of general error-free low level functions
- Possibly allow companies to place code (on their own intranet wikis) to allow code to be broght up to date on a continous basis as opposed to a massive update of entire applications.
- Provide the same functions in multiple programming langugaes
Termanology
Base Level
Functions show generally be at a base level to optomize their usuability (the ability of the functions to be used by a large number of users), simplicity/transpancy (the degree of dificulty in unserstanding the code), lack of errors.
Higher level functions can be written but they should call lower level functions.
General Outline of a non language specific function
- Name of function
- catagory of function
- Purpose of Function
- inputs
- outputs
- PDL
- Languages avliable
- Subfunctions
General Outline of a language specific function
- Name of function
- Language
- catagory
- purpose
- inputs
- outputs
- langage specifc PDL
- code
- prototype
- declaration
- example of usage
- example of output
- subfucntions
- other languages avliable
Example Function
- Name: GetWorkingDays
- Language :VB
- Catagory:Data\Time
- Inputs:Date1 Date2
- Outputs:Integer
- Purpose:Function returns the number of weekdays between date1 and date2
- Code:
Origonal copy
Function GetWorkingDays(ByVal Date1, ByVal Date2) '======================================= ' returns the number of weekdays (i.e., excluding Sat/Sun) ' between 2 dates. ' ' As implemented, Date1 should not be greater than Date2 ' (but is not verified). A more versatile version could ' allow for inverted dates and calculate and return a ' negative value. To be more robust, the arguments should ' also be verified as valid dates. ' Also adding a database of holidays can help '======================================= Dim TotalDays, FullWeeks, OddDays, n TotalDays = DateDiff("d", Date1, Date2) FullWeeks = TotalDays \ 7 OddDays = TotalDays Mod 7 GetWorkingDays = FullWeeks * 5 For n = 0 To OddDays - 1 Select Case Weekday(DateAdd("d", n, Date1)) Case vbSaturday, vbSunday 'ignore Case Else : GetWorkingDays = GetWorkingDays + 1 End Select Next Return GetWorkingDays End Function
Usage:
Dim start,end as Date start = 1/5/2005 end = 6/26/2005 Dim x as interger = GetWorkingDays( start, end )
Try it Out
Edit the function below
Function GetWorkingDays(ByVal Date1, ByVal Date2) '======================================= ' returns the number of weekdays (i.e., excluding Sat/Sun) ' between 2 dates. ' ' As implemented, Date1 should not be greater than Date2 ' (but is not verified). A more versatile version could ' allow for inverted dates and calculate and return a ' negative value. To be more robust, the arguments should ' also be verified as valid dates. ' Also adding a database of holidays can help '======================================= Dim TotalDays, FullWeeks, OddDays, n TotalDays = DateDiff("d", Date1, Date2) FullWeeks = TotalDays \ 7 OddDays = TotalDays Mod 7 GetWorkingDays = FullWeeks * 5 For n = 0 To OddDays - 1 Select Case Weekday(DateAdd("d", n, Date1)) Case vbSaturday, vbSunday 'ignore Case Else : GetWorkingDays = GetWorkingDays + 1 End Select Next Return GetWorkingDays End Function
Post the function in another programming langauge
- Language: ?