杂细节时需要内部注释。 应在脚本的开始部分包含描述该脚本的概述,列举对象、过程、运算法则、对话框和其他系统从属物。有时一段描述运算法则的假码是很有用的。 格式化代码应尽可能多地保留屏幕空间,但仍允许用代码格式反映逻辑结构和嵌套。以下为几点提示: - 标准嵌套块应缩进 4 个空格。
- 过程的概述注释应缩进 1 个空格。
- 概述注释后的最高层语句应缩进 4 个空格,每一层嵌套块再缩进 4 个空格。例如:
''*********************************************************'' Purpose: Locates the first occurrence of a specified user '' in the UserList array.'' Inputs: strUserList(): the list of users to be searched.''strTargetUser: the name of the user to search for.'' Returns: The index of the first occurrence of the strTargetUser '' in the strUserList array. '' If the target user is not found, return -1.''*********************************************************Function intFindUser (strUserList(), strTargetUser)Dim i'' Loop counter.Dim blnFound'' Target found flagintFindUser = -1i = 0'' Initialize loop counterDo While i <= Ubound(strUserList) and Not blnFoundIf strUserList(i) = strTargetUser Then blnFound = True'' Set flag to TrueintFindUser = i'' Set return value to loop countEnd Ifi = i + 1'' Increment loop counterLoopEnd Function
|