' sample statement written in the calling routine Sub Calculate() Hs.Exp "A#AVG_SALES = " & Average("A#Sales", "12") End Sub ' programming of the AVERAGE function FUNCTION Average(strPOV,strPERIOD) DIM nPERIOD DIM strCUM DIM i strPOV = UCASE(strPOV) strPERIOD = UCASE(strPERIOD) IF strPERIOD = "PERIODIC" THEN IF HS.PERIOD.ISFIRST = TRUE THEN nPERIOD = 1 ELSE nPERIOD = 2 END IF ELSEIF strPERIOD = "YTD" THEN nPERIOD = HS.PERIOD.NUMBER() ELSEIF CINT(strPERIOD) > 0 THEN nPERIOD = CINT(strPERIOD) ELSE EXIT FUNCTION END IF FOR i = 0 TO nPERIOD-1 IF i = 0 THEN strCUM = strPOV &".W#PERIODIC" ELSE strCUM = strCUM &"+"& strPOV &".W#PERIODIC.P#CUR-"&i END IF NEXT Average = "(("& strCUM &")/"& nPERIOD &")" END FUNCTION