Concat the list that have variable that changed in a loopHi,
I'm struggle to concat multiple list that has variable in it. I have a list, each item is string that is concatenated from a user-input variable. Since the variable is changed per loop, how I can get the list updated, and concat that list to other lists.
bank_pcs = {"BGB1BESS001_B"||bank||"_W","BGB1BESS001_B"||bank||"_A","BGB1BESS001_V"||bank||"_W"};
For (i = 1, i<=6, i++,
bank_num = 6*(k-1)+i;
bank = char(bank_num,10,0);
Eval list (bank_pcs);
bank_tags_i = bank_pcs;
bank_tags = concat (bank_tags, bank_tags_i)
)Thanks
Data Blending and CleanupRe: Concat the list that have variable that changed in a loopSee if this will give you what you want
For( i = 1, i <= 6, i++,
bank_num = 6 * (k - 1) + i;
theBankValue = Char( bank_num, 10, 0 );
Eval(
Substitute(
Expr(
bank_pcs = {"BGB1BESS001_B" || bank || "_W", "BGB1BESS001_B" || bank || "_A", "BGB1BESS001_V" || bank ||
"_W"}
),
Expr( bank ), theBankValue
)
);
bank_tags_i = bank_pcs;
bank_tags = Concat( bank_tags, bank_tags_i );
);Re: Concat the list that have variable that changed in a loopYou were almost there. You had the evallist(bank_pcs) but that's not what you're assigning to bank_tags_i. This works for me.
NamesDefaultToHere(1);
bank_pcs = {"BGB1BESS001_B"||bank||"_W","BGB1BESS001_B"||bank||"_A","BGB1BESS001_V"||bank||"_W"};
For (i = 1, i<=6, i++,
bank_num = i; // changing this from yours because I assume you also have a k loop
bank = char(bank_num,10,0);
bank_tags_i = Evallist(bank_pcs);
if(i==1,
bank_tags = bank_tags_i // just if it isn't started yet. you're probably doing this in your k loop
, //else
bank_tags = concat (bank_tags, bank_tags_i)
)
);
bank_tags;Re: Concat the list that have variable that changed in a loopor, if you want a list-of-lists:
k = 11;
bank_tags = {};
bank_pcs = {"BGB1BESS001_B" || bank || "_W", "BGB1BESS001_B" || bank || "_A", "BGB1BESS001_V" || bank || "_W"};
For( i = 1, i <= 6, i++,
bank_num = 6 * (k - 1) + i;
bank = Char( bank_num, 10, 0 );
bank_tags_i = Eval List( bank_pcs );
bank_tags[1 + N Items( bank_tags )] = bank_tags_i;
);
Show( bank_tags );
/*{{"BGB1BESS001_B61_W", "BGB1BESS001_B61_A", "BGB1BESS001_V61_W"},
{"BGB1BESS001_B62_W", "BGB1BESS001_B62_A", "BGB1BESS001_V62_W"},
{"BGB1BESS001_B63_W", "BGB1BESS001_B63_A", "BGB1BESS001_V63_W"},
{"BGB1BESS001_B64_W", "BGB1BESS001_B64_A", "BGB1BESS001_V64_W"},
{"BGB1BESS001_B65_W", "BGB1BESS001_B65_A", "BGB1BESS001_V65_W"},
{"BGB1BESS001_B66_W", "BGB1BESS001_B66_A", "BGB1BESS001_V66_W"}}*/
If you want a string rather than a list, try @vince_faller answer with Concat Items( bank_tags, "," ) to get the list items in a string with commas.
Re: Concat the list that have variable that changed in a loopThank you! It works just as I expected.