I'm new to this, so I am likely lacking the proper syntax. Basically my problem is this, I am trying to match variables in array2 with elements in array1, but Batch is skipping the spaces in my variables. Not sure if I am articulating myself sufficiently here.
Here is my code:
@ECHO OFF
SET VAR1=One TWO THREE
SET VAR2=ALPHA BETA
SET VAR3=hello world
SET ARRAY1=ENTRY1 ENTRY2 ENTRY3
SET ARRAY2=%VAR1% %VAR2% %VAR3%
FOR %%a IN (%ARRAY1%) DO (
CALL :secondpart
)
PAUSE
EXIT
:secondpart
FOR %%b IN (%ARRAY2%) DO (
ECHO %%a = %%b
)
EXIT /b
My output is this:
ENTRY1 = One
ENTRY1 = TWO
ENTRY1 = THREE
ENTRY1 = ALPHA
ENTRY1 = BETA
ENTRY1 = hello
ENTRY1 = world
ENTRY2 = One
ENTRY2 = TWO
ENTRY2 = THREE
ENTRY2 = ALPHA
ENTRY2 = BETA
ENTRY2 = hello
ENTRY2 = world
ENTRY3 = One
ENTRY3 = TWO
ENTRY3 = THREE
ENTRY3 = ALPHA
ENTRY3 = BETA
ENTRY3 = hello
ENTRY3 = world
The output I'm expecting is this:
ENTRY1 = One TWO THREE
ENTRY1 = ALPHA BETA
ENTRY1 = hello world
ENTRY2 = One TWO THREE
ENTRY2 = ALPHA BETA
ENTRY2 = hello world
ENTRY3 = One TWO THREE
ENTRY3 = ALPHA BETA
ENTRY3 = hello world
Anyone have any idea how to fix this?