[Solved] Use a declared variable as a token in For loop
Hello all.. I was wondering if it's possible to use a declared variable as a token in a for /f loop ? For instance I have something like:
For /f "tokens=%Variable% delims=;" %%b in ...blah blah do ..
Have tried it even with enabled variable extensions with no luck!
The interpreter seems to take '%Variable%' as the actual token.. Is there a way to work around this so that the Token is interpreted as the declared valid integer value from the variable?
Basically, it is possible to make delims as a variable... Try the following Code:
For /f "tokens=1,2,3 delims=%_delims%" %%A in ("%_set%") do (Echo %%A - %%B - %%C)
And, making tokens as a variable is also seems to be possible to accomplish... Try the following Code:
For /f "tokens=%_tokens% delims=," %%A in ("%_set%") do (Echo %%A - %%B - %%C)
Please also See the attached files - They might help you!
It's worth mentioning that variables that get used for for /f loops get parsed before regular variable expansion, so if you're using delayed expansion variables, this won't work.