Im trying to do this rather elementary thing in a DOS batch:
@echo off
set _sets=^
RO:111:Rondonia,^
AC:112:Acre,^
AM:113:Amazonas,^
RR:114:Roraima
set _family_name=MyFamily
FOR %%i IN (%_sets%) DO (
echo %%i ----- %_family_name%
)
Output:
RO:111:Rondonia -----
AC:112:Acre -----
AM:113:Amazonas -----
RR:114:Roraima -----
After the ----- is supposed to appear "MyFamily", but instead nothing appears.
How do I access variables set outside a FOR loop from within it? I have no idea why the _family_name variable is not visible inside the for loop. I'm somewhat new to batch scripts. I'm used to C++ and Java programming, thus most likely my thinking does not apply to the batch realm.
I also need to split the string triplets "AA:NNN:AAAAAA" into three individual variables. I tried to come up with a nested for loop, but I couldn't tackle this problem.
The example was made simple for clarity. The actual Batch is more complex than that. I have to access 10-12 variables from within the loop. So please consider this aspect before answering. Thanks in advance.
RO:111:Rondonia ----- MyFamilyand so forth.