I have the following Array/List setup. The first position in the list is a filename mask. What's interesting is if I have 2 like file names but still unique, when I clear the array before each iteration, the other like array definition is cleared too.
For instance, when running the below code only 1 array/list definition is registered. However, if I switch "PRODUCT_PARENT" to "PARENT_PRODUCT", it works fine. Why does the array clear seem to do a partial match when clearing?
Code: Select all
@ECHO OFF
SETLOCAL ENABLEDELAYEDEXPANSION
FOR %%a IN (
"PRODUCT_PARENT|DLR_PROD_PARENT_LOAD|inbox/Metadata|REPLACE|STORE_DATA|||"
"PRODUCT|DLR_IMP_PROD|inbox/Metadata|REPLACE|STORE_DATA|||"
) DO SET "GROUP=%%~a" & CALL :DEFINE_LISTS "DM" "MD"
REM Display Arrays
SET STR[
pause
:DEFINE_LISTS
IF /I "[%~2]"=="[D]" SET "TYPE=Data"
IF /I "[%~2]"=="[MD]" SET "TYPE=Metadata"
SET "GROUP=!GROUP:||=|null|!"
FOR %%v IN ("!GROUP:||=|null|!") DO FOR /F "tokens=1-13 delims=|" %%A IN ("%%~v") DO (
REM Clear Array
FOR /F "delims==" %%1 IN ('SET STR[%%A') DO SET "%%1="
IF NOT "[%%B]"=="[null]" SET "STR[%%A].DLR=%%B"
IF NOT "[%%C]"=="[null]" SET "STR[%%A].LOC=%%C"
IF NOT "[%%D]"=="[null]" SET "STR[%%A].IMP=%%D"
IF NOT "[%%E]"=="[null]" SET "STR[%%A].EXP=%%E"
IF NOT "[%%F]"=="[null]" SET "STR[%%A].RMT_LOGIN=%%F"
IF NOT "[%%G]"=="[null]" SET "STR[%%A].DEL=%%G"
IF NOT "[%%H]"=="[null]" SET "STR[%%A].TLOC=%%H"
IF NOT "[%%J]"=="[null]" SET "STR[%%A].INTRA=%%J"
IF NOT "[%%K]"=="[]" IF NOT "[%%K]"=="[null]" (
SET "STR[%%A].CCNTS=%%K"
SET "CCNTS=%%K"
)
IF NOT "[%%L]"=="[]" IF NOT "[%%L]"=="[null]" SET "STR[%%A].CCNTD=%%L"
IF NOT "[%%M]"=="[]" IF NOT "[%%M]"=="[null]" SET "STR[%%A].DLOCD=%%M"
SET "STR[%%A].TYPE=!TYPE!"
)
CLS
GOTO :EOF