HFM Hints and Tips
HFM Hints and Tips
HFM Hints and Tips
‘***
‘ Large sections of code should be commented like this.
‘
End Sub
See http://java.sun.com/j2se/javadoc/writingdoccomments/ for authoritative code documentation
standards.
Justification
• Adapts standard commenting style to VBScript.
• ‘*** is quicker to create and maintain than the normal VBScript commenting styles.
Const Statement
Tip
Use the Const statement to declare constants.
Justification
Rules files sometimes declare constants as global variables as follows:
Dim AllTops
Dim AllTopsXC1
Sub Calculate()
Sub Calculate()
The values of constants created using this syntax cannot be altered.
Constant Names
Tip
Constant names should be upper case with words separated by underscores.
Justification
• Capitalisation is standard practice.
• Underscores make names more readable.
Justification
Hyperion Financial Management (HFM) rules sometimes have For loops as follows:
AccountList = HS.Account.List("A#Register","[Base]")
For i = Lbound(AccountList) To Ubound(AccountList)
‘Code in loop
Next
These can be changed to For Each loop as follows:
AccountList = HS.Account.List("A#Register","[Base]")
For Each AccountMember In AccountList
‘Code in loop
Next
For Each loops are:
• Simpler
• Easier to read and understand.
• Probably quicker as array length does not have to be calculated for every loop.
If Then Versus Select Case
Tip
Generally If … End If should be used. Select Case… End Select should only be used where it
significantly more concise and improves readability.
Justification
If…End If is more like natural language and normally easier to use than Select Case…End Select.
However, sometime Select Case…End Select produces more readable code and is preferred.
Examples
If CurrentMonth = “Jan” Then
‘Code
ElseIf CurrentMonth = “Feb” Then
‘Code
ElseIf CurrentMonth = “Mar” Then
‘Code
End If
Is preferable to:
Select CurrentMonth
Case “Jan”
‘Code
Case “Feb”
‘Code
Case “Mar”
‘Code
End Select
But
EndTime = Timer
WriteToFile("Took = " & (EndTime - StartTime))
1
Microsoft Windows Script Technologies documentation.
2
Code Complete.
3
Code Complete.
4
This is a bit verbose I would normally use Account and Accounts but these names conflict with names used by the HS
object so I use AccountMember and AccountsList in HFM.