There isn't any way to tell the FOR command not to treat consecutive delims as a single delim. The way I typically work around this is to "pre process" the input line and look for pairs of delims with nothing between them. I replace these with something in between the delims that I can then check for in the code and treat as a missing or empty value.
So if the input line was
aaa,,,bbb
And I want to process 4 values rather than the 2 that the FOR will pickup by default, then I first convert the line to
aaa,@,@,bbb
and then feed that into the FOR and parse on comma.
I'm attaching the code with this change, let me know how it goes for you. I made a couple of other small adjustments, let me know what questions you have.
- needed to add the setlocal EnableDelayedExpansion so that I could update and use a variable inside a loop
- defined the input file name as a variable, and quoted it in the main FOR that reads it, to handle the case where the filename could include spaces
- the outer FOR loop reads the entire line, then we assign that to a variable so that we can replace the "empty" values with a placeholder (I used @, could be anything you like)
- then another FOR much like your original one parses the resultant string and calls the subroutine
- I added an ECHO of the inputline before and after the conversion just so you can see how it works, these would be removed later
Hope this helps
~bp