A very used statement in C# is the foreach statement. A loop that traverse any structure with a enumerator. This is now present in NAV2016, only on dotnet variables so far.
Here is an example from the OCR/Document module of NAV0216.
An outer loop of all the child nodes in a xml node, and the an inner loop of all the “DocumentId” childs of the first node.
FOREACH XMLNode IN XMLRootNode.ChildNodes DO BEGIN ChildNode := XMLNode.SelectSingleNode('BatchExternalId'); ExternalBatchId := ChildNode.InnerText; IF (ExternalBatchFilter = '') OR (ExternalBatchFilter = ExternalBatchId) THEN FOREACH ChildNode IN XMLNode.SelectNodes('DocumentId') DO BEGIN DocId := ChildNode.InnerText;
Another example, goes through all the elements of an dotnet Array:
FOREACH Table IN TableList DO BEGIN Name := FilterPageBuilder.ADDTABLE(GetTableCaption(Table),Table); AddFields(FilterPageBuilder,Name,Table); END;
So far, it looks like FOREACH is only present in “new” objects in NAV2016.