Please enable JavaScript to view this site.

A-Shell Reference

Updated August 2018; 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

2023 August, A-Shell 6.5.1739:  In FOREACH, if the specified starting key is not found, the iteration now starts with the next key. Previously, the result would have been an empty iteration. In FOREACH'REVERSE, the starting key is now recognized whereas previously it was ignored. As with FOREACH, if not found, the iteration starts with the next key—i.e. the next one lower in the collating sequence.

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.