Loops/Foreach: Difference between revisions
Content added Content deleted
Simple9371 (talk | contribs) |
Simple9371 (talk | contribs) |
||
Line 274: | Line 274: | ||
=={{header|Batch File}}== |
=={{header|Batch File}}== |
||
The FOR command can imitate the "Foreach Loop". The whitespace and the comma (,) are the default delimiters. |
The FOR command can imitate the "Foreach Loop". The whitespace and the comma (,) are the default delimiters.<br> |
||
'''Direct usage:''' |
'''Direct usage:''' |
||
<lang dos>@echo off |
<lang dos>@echo off |
||
for %%A in (This is a sample |
for %%A in (This is a sample collection) do ( |
||
echo %%A |
echo %%A |
||
)</lang> |
)</lang> |
||
'''Using a Collection Variable:''' |
'''Using a Collection Variable:''' |
||
<lang dos>@echo off |
<lang dos>@echo off |
||
set "collection=This is a sample |
set "collection=This is a sample collection" |
||
for %%A in (%collection%) do ( |
for %%A in (%collection%) do ( |
||
echo %%A |
echo %%A |