Main Help → GENerel Commmands → RepeatWith Loops
The RepeatWith command functions differently when used in browser styles than when used in internal scripts.
In Browser Styles, the RepeatWith command reads multiple tags in order and passes the results to a Repeat loop.
RepeatWith #1 from #2 ... ... EndRepeat
where
#x", or an expression that evaluates to a variable name) from between #1 and #2 is optionalThis command will read all tags corresponding to the GEDCOM expression in #2, load each result into the variable (e.g., #x), and then process the repeat loop code.
This command is only needed when multiple tags need to be accessed. For example:
RepeatWith "#chil" from @FAMS.CHIL ... ... EndRepeat
will execute the loop once for each child of an individual in one family record. Within the loop, #chil will contain the record ID of a child.
In Internal Scripts, the RepeatWith command iterates through objects or strings in a list, objects in a GC list, or values in a dictionary and passes them to a Repeat loop.
RepeatWith #1 from #2 ... ... EndRepeat
where
"#x", is provided, the '#' will be removed and #1 set to remaining characters, such as "x" (as explained below, this change is needed to allow iterating lists that might have both strings and objects).This command will iterate through items in the list, load each result into the variable or object name provided in #1, and then process the repeat loop code. The variable or object name that gets set depends on the item in the list:
By this process you can iterate items in lists having both strings and objects and loop statements can check on type if needed. Sample code would be:
RepeatWith "var" from alist
ifdef #var
! statements when get a string or number using "#var"
else
! statement when get an object named "var"
endif
EndRepeat
If a list is known to contain only strings and numbers or only objects, the loop need not check each one.