Creating Function and Procedure Headers

Microsoft® Windows® 2000 Scripting Guide

Each function and procedure in a script should also have a header that describes the purpose of that function or procedure. Information typically included in a function or procedure header is shown in Table 18.6.

Table 18.6 Function and Procedure Headers

Header Item

Description

Name

Label applied to the function or procedure within the script. Follow the guidelines described in "Naming Scripts" earlier in this chapter.

Purpose

General explanation of the task performed by the function or procedure.

Arguments supplied

Data (usually in the form of variables) passed to the function or procedure.

Return value

Result returned from the function or procedure.

Function is called by

Name of the function or procedure that calls this section of the script. Omit if called from within the main body of the script.

Function calls

Name of any functions or procedures that are called from within this section of the script. Omit if no such calls are made. Both this header item and the preceding header item help you to trace program flow.

A sample function header might look like this:

'*  Function Name:            CalculateTotalPay()
'*  Purpose:                  Calculates total pay for an employee based on
'*                            current salary plus merit increase.
'*  Arguments supplied:       intUserIDNumber, curCurrentSalary, intMeritRank
'*  Return Value:             curRevisedSalary
'*  Function is called by:    SalaryAdjustment
'*  Function calls:           ConvertMeritRank