Can anyone guide me what this script about? please

Hi Guys…hope some one will help me out with this script and let me know exactly what this script does.ill be very grateful if someone let me know step by step how this script works.Thanks in advance!

Function calcDebtTurn(days() As Integer, TurnOver() As Double, SLBal() As Double, result() As Double ) As Integer

On Error Goto errhandle	

Dim nRows As Integer,nDays As Integer, nkeepgoing As Integer, i As Integer, x As Double, tempi As Integer

Dim nOSBal As Double

calcDebtTurn = 1	

nRows = Ubound(days)

If Ubound(TurnOver) < nRows Or Ubound(SLBal) < nRows Then

	calcDebtTurn = -2

Else		

	Redim Preserve result(nRows)				

	For i = nRows To  0  Step -1

		nosBal = SLBal(i)

		nkeepgoing = True

		ndays = 0 							

		tempi = i

’ tempi = i-1

’ If tempi >= 0 Then

		Do While nkeepgoing = True

			If TurnOver(tempi) >=nosBal Then

				x = nosbal * days(tempi)/Turnover(tempi)

				If tempi = 0 Then

					ndays = 0 

				Else

					ndays = ndays + x 

				End If 					

				nkeepgoing = False 				

			Else

				If tempi = 0 Then

					calcDebtTurn = -1					

					ndays = 0 

					nkeepgoing = False 									

				Else

					ndays = ndays+days(tempi)

				End If

			End If													

			nOSBal = nOSBal-Turnover(tempi)				

			tempi =tempi-1

		Loop

’ End If

		Result(i) = nDays

	Next	

End If	

Exit Function

errhandle:

Resume Next 	

End Function

Function calcTriggerBite() As Integer

Dim ws As New notesuiworkspace

Dim uidoc As notesuidocument

Dim doc As notesdocument

Dim item As notesitem

Dim i As Integer, nRows As Integer

Dim result() As String	

Set uidoc = ws.currentdocument

Set doc = uidoc.document

Set item = doc.getFirstItem("FStats_nDebtTurn")

If Not item Is Nothing Then

	nRows = Ubound(item.values)		

	Redim result(nrows)

	For i = 0 To nrows

		If item.values(i) > doc.FStats_nTotTrigger(0) Then

			result(i) = "§"

		Else

			result(i) = "."

		End If 

	Next

End If 

Call doc.replaceItemValue("FStats_tTrigger",Result)			

Exit Function

errhandle:

Resume Next 	

End Function

Subject: RE: can anyone guide me what this script about?? please

The way to find out step by step what a script does, is to step through it line by line yourself and see what is does. What, do you want an English description like, “Assign 1 to the variable i”?

Neither routine calls the other, so their relationship to each other is unclear. I’m guessing there’s some other routine that calls the first function, places the result it returns into a field, then calls the second function.

In summary what it appears to be doing is:

The first function apparently calculates some financial function called debt turnover. An accountant might be able to explain what the meaning of this value is. Since it takes several arrays as arguments, I guess the arrays are probably read from multi-value fields displayed in a table, one column per field.

In the second routine, we’re processing FStats_nDebtTurn, another multivalue field (i.e. one table column) from this table, and comparing the values to the field FStats_nTotTrigger, which is some threshold amount (probably the value calculated by the first function). FStats_nDebtTurn was probably also an input to the first function.

The result of the calculations is an array of values that’s put into another multi-value field, FStats_tTrigger, which I assume is another column in the table. Each value in the result is a one-character string, and I’m assuming the field is formatted to use a symbolic font – Wingdings, perhaps – to make the character display as an icon, flagging the rows that exceeded the threshold value.

So overall, it looks like what’s happening is that based on the values in a table, you’re calculating some value which is something sort of like an average or natural break-point of the table values, then visually flagging the table rows containing values that exceed that average.

  • Andre Guirard, IBM/Lotus Development

Useful blog: Best Practice Makes Perfect

For faster answers, be C R I S P Y