Windows Batch: acessing variables from inside FOR loop -
im trying rather elementary thing in dos batch:
@echo off set _sets=^ ro:111:rondonia,^ ac:112:acre,^ am:113:amazonas,^ rr:114:roraima set _family_name=myfamily %%i in (%_sets%) ( echo %%i ----- %_family_name% )
output:
ro:111:rondonia ----- ac:112:acre ----- am:113:amazonas ----- rr:114:roraima -----
after ----- supposed appear "myfamily", instead nothing appears.
how access variables set outside loop within it? have no idea why _family_name variable not visible inside loop. i'm new batch scripts. i'm used c++ , java programming, thinking not apply batch realm.
i need split string triplets "aa:nnn:aaaaaa" 3 individual variables. tried come nested loop, couldn't tackle problem.
the example made simple clarity. actual batch more complex that. have access 10-12 variables within loop. please consider aspect before answering. in advance.
if _family_name
being set within (outer) loop, you'll need enable delayed expansion this:
@echo off setlocal enabledelayedexpansion ... set foo=bar ... echo !foo! ) )
note access variable !exclamations!
instead of %percents%
there.
Comments
Post a Comment