Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I can't believe this is so complicated! Seems like everyone would want to split a string frequently without knowing how many tokens are in it and without parsing it by lines. Typically, it seems people are writing to a file and then step through it or using a multi sub method like these others. What a mess!</p> <p>Here's my solution. It's easier to follow and works inline, i.e. no sub routine. It is nice to build a list of filenames or whatever and then step through them without having to write to them to a temp file, ensure there is no file writing collision, delete the temp file etc. Plus I don't know how to return a value from a sub like it was a function - I don't think you can. So you'd have to keep writing 2 subs with the other answers I see here each time you wanted to do something like this - one that feeds the other. My method lets you easily create lists and step through them as many times as you want throughout the script.</p> <pre><code>setlocal enableextensions enabledelayedexpansion set SomeList= set SomeList=!SomeList!a; set SomeList=!SomeList!b; set SomeList=!SomeList!c; set SomeList=!SomeList!d; set SomeList=!SomeList!e; set SomeList=!SomeList!f; set SomeList=!SomeList!g; set List=!SomeList! :ProcessList FOR /f "tokens=1* delims=;" %%a IN ("!List!") DO ( if "%%a" NEQ "" ( echo %%a ) if "%%b" NEQ "" ( set List=%%b goto :ProcessList ) ) </code></pre> <p>Output:</p> <pre><code>a b c d e f g </code></pre> <p>Obviously you can just exchange the echo with something useful.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload