cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Don’t miss your chance to experience Discovery Summit Europe at our best available rate! Early bird registration through 31 Oct.
  • Graph Builder Toolbar streamlines interactive graphing. Creates shortcuts on Report and GraphBuilder Helpers toolbars. Download and install the extension.
  • JMP will suspend normal business operations for our Rest and Recharge Day on Friday, October 2, 2026.
    Regular business hours will resume on Monday, October 5, 2026.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
mquyen
Level II

Concat the list that have variable that changed in a loop

Hi, 
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

1 ACCEPTED SOLUTION

Accepted Solutions
vince_faller
Super User (Alumni)

Re: Concat the list that have variable that changed in a loop

You 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;
Vince Faller - Predictum

View solution in original post

4 REPLIES 4
txnelson
Super User

Re: Concat the list that have variable that changed in a loop

See 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 );
);
Jim
vince_faller
Super User (Alumni)

Re: Concat the list that have variable that changed in a loop

You 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;
Vince Faller - Predictum
Craige_Hales
Super User

Re: Concat the list that have variable that changed in a loop

or, 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.

Craige
mquyen
Level II

Re: Concat the list that have variable that changed in a loop

Thank you! It works just as I expected. 

Recommended Articles