RepeatWith Command

The RepeatWith command functions differently when used in browser styles than when used in internal scripts.

RepeatWith in Browser Styles

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

This 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.

Notes

  1. If no data is found, the repeat loop will not be executed at all.
  2. The loop to be executed can use all options of repeat loops.
  3. If you do not want to execute more code for each found result, it is more direct to use the ReadAll command instead.

RepeatWith in Internal Scripts

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

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:

  1. If the item is a string or a number, the loop will set a variable with name having number sign ('#') in front of argument #1 and it will undefine argument #1 as an object.
  2. All other types of items are objects and loop will set object name in argument #1 to the list item and undefine variable with name having number sign ('#') in front of argument #1.

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.

Notes

  1. If the list is empty, the repeat loop will not be executed at all.
  2. The loop to be executed can use all options of repeat loops.
  3. The "from" is required (but alternatively can be "in")
  4. Available since 3.5/1.0