GenoPro Home
GenoPro Home  |  SDK Home  |  Report Generator  |  Support  |  Search  |  Help  |  Site Map

Skip Navigation Links.

Report.Loop Properties

This page contains the documentation for all Loop properties of the Report object and some properties of the ReportGenerator object.


Those properties allow easy access to the looping parameters from the configuration file. If the report template has no "for loop", those properties return "empty data", such as an empty string for the collection name, zero for the item count, -1 for the loop index, and Nothing for the loop item.

To get started, let us take a look at a sample configuration file as below.

	<Report Template="individual.htm"
		LoopItemName="i" />

The presence of the For attribute indicates the presence of a loop by assigning a collection to a template. In this example, the collection is Individuals and the template is individual.htm. In other words, the template individual.htm will be applied for each individual found in the genealogy tree. The presence of the attribute LoopItemName is optional; if missing, GenoPro will synthesize a loop item name using the first letter of the collection name Individuals.


This property may be useful when you are generating a super-generic template and need to tweak the code for a specific collection. For instance, you may have an HTML template generating an alphabetical index of a collection, however for the collection Families, you want a different sorting. You would then compare LoopCollectionName to "Families" and perform a different sorting if necessary. You can also get the collection with the following code:

strCollectionName = Report.LoopCollectionName ' Get the collection name
Dim collectionLoop
Set collectionLoop = ReportGenerator.Document.Collection(strCollectionName)
For Each oObject In collectionLoop 
	Report.WriteTextBr oObject


The property LoopItemName returns a string representing the name of the loop item. In our example, the value would be the string "i", representing the name of the global variable storing the loop item object. The presence of the attribute LoopItemName in the configuration file is to make the code easier to understand and reduce typing. On the other hand, the presence of the property Report.LoopItemName is useless in a report. This property is present for documentation completeness and removes any possible ambiguity between a loop item name and a loop item object.

LoopItem (object)

Returns the current object of the loop item, or Nothing if there is no loop.


Returns the total number of items in the collection. You may use this property in your report to write something like this "Picture 5 of 150". The code would look like this:

Report.WriteFormatted "Picture {} of {}", Report.LoopItemIndex + 1, Report.LoopItemCount


The loop index is useful to determine which item is being processed. You may use the loop index to perform some special processing to the first or last element in the loop, such as initializing some data structures or loading a special module to generate code for the entire collection. Similarly, you may use the loop index to unload the objects when done generating the last loop item.

If (Report.LoopItemIndex = Report.LoopItemCount - 1) Then
	' Unload the object oXML from memory
	Session("oXML") = Nothing
End If

Like all indices, the loop index starts at zero. Therefore the first item is at position zero and the last item is at position LoopItemCount - 1.


The use of these property is seldom, however you may have a super generic HTML template where you need to to access a specific value to perform additional processing.

The following is a sample code displaying all the attributes related to template looping. You are welcome to paste this code to your own template and see the result for yourself.

Report.WriteFormattedBr "ReportGenerator.PathOutput: <b>{&t}</b>", ReportGenerator.PathOutput
Report.WriteFormattedBr "ReportGenerator.PathOutputFtp: <b>{&t}</b>", ReportGenerator.PathOutputFtp
Report.WriteFormattedBr "ReportGenerator.PathOutputHttp: <b>{&t}</b>", ReportGenerator.PathOutputHttp
Report.WriteFormattedBr "ReportGenerator.PathSkin: <b>{&t}</b>", ReportGenerator.PathSkin
Report.WriteFormattedBr "Report.FileTemplate: <b>{&t}</b>", Report.FileTemplate
Report.WriteFormattedBr "Report.FileOutput: <b>{&t}</b>", Report.FileOutput
Report.WriteFormattedBr "Report.LoopCollectionName: <b>{&t}</b>", Report.LoopCollectionName
Report.WriteFormattedBr "Report.LoopItemName: <b>{&t}</b>", Report.LoopItemName
Report.WriteFormattedBr "Report.LoopItemCount: <b>{}</b>", Report.LoopItemCount
Report.WriteFormattedBr "Report.LoopIndex: <b>{}</b>", Report.LoopIndex
Set oLoopItem = Report.LoopItem
If (Not Util.IsNothing(oLoopItem)) Then
    Report.WriteFormattedBr "Report.LoopItem: <b>{&t}</b> (Class: <b>{}</b>)", oLoopItem, oLoopItem.Class
End If

This is a sample output when the code was executed in the template individual.htm. The sample tree used to generate the report had 15 individuals, and the fourth individual (LoopIndex = 3) is Estelle Morin. Please observe the use of the property Class. This property is almost identical to the LoopCollectionName, however its name is the singular form (typically without the s).

ReportGenerator.PathOutput: C:\My Documents\GenoPro Report\
ReportGenerator.PathSkin: C:\Program Files\GenoPro\Skins\English\
Report.FileTemplate: individual.htm
Report.FileOutput: ind00004.htm
Report.LoopCollectionName: Individuals
Report.LoopItemName: i
Report.LoopItemCount: 15
Report.LoopIndex: 3
Report.LoopItem: Estelle Morin (Class: Individual)

If the same code is executed on a template without a collection such as home.htm, the following output is produced:

ReportGenerator.PathOutput: C:\My Documents\GenoPro Report\
ReportGenerator.PathSkin: C:\Program Files\GenoPro\Skins\English\
Report.FileTemplate: home.htm
Report.FileOutput: home.htm
Report.LoopItemCount: 0
Report.LoopIndex: -1


See Also:



Copyright ┬ę 1998-2024. All rights reserved. GenoPro┬« and the GenoPro logo are registered trademarks.