FOREACH

Update May 2017; see History

FOREACH $$<itervar> in $<aryvar>({<startkey>})

     <statements>

     {IF <condition> REPEAT}

     {IF <condition> EXIT}

     {<statements>}

NEXT $$<itervar>

 

FOREACH'REVERSE $$<itervar> in $<aryvar>()

     <statements>

     {IF <condition> REPEAT}

     {IF <condition> EXIT}

     {<statements>}

NEXT $$<itervar>

 

The foreach and foreach'reverse loops are used to iterate through Ordered Maps, which see for details.

History

2018 May, A-Shell 6.5.1636, compiler edit 859:  the starting key in a FOREACH statement may now be any kind of expression. Previously, it only allowed a simple variable or a literal string or numeric constant; numeric literals were allowed but weren't converted to string and thus typically failed to match any items in the map.