cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP will suspend normal business operations for our Winter Holiday beginning on Wednesday, Dec. 24, 2025, at 5:00 p.m. ET (2:00 p.m. ET for JMP Accounts Receivable).
    Regular business hours will resume at 9:00 a.m. ET on Friday, Jan. 2, 2026.
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.

Discussions

Solve problems, and share tips and tricks with other JMP users.
%3CLINGO-SUB%20id%3D%22lingo-sub-533192%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%E5%9C%A8%20Collistbox()%20%E4%B8%8A%E4%BD%BF%E7%94%A8%20Try()%20%E6%99%82%E5%87%BA%E9%8C%AF%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-533192%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E5%9F%BA%E6%9C%AC%E4%B8%8A%E6%88%91%E6%AD%A3%E5%9C%A8%E6%A7%8B%E5%BB%BA%E4%B8%80%E5%80%8B%E5%8C%85%E5%90%AB%E4%B8%8D%E5%90%8C%E9%A1%AF%E7%A4%BA%E6%A1%86%E7%9A%84%E8%87%AA%E5%AE%9A%E7%BE%A9%E4%BA%A4%E4%BA%92%E5%BC%8F%E7%AA%97%E5%8F%A3%EF%BC%8C%E4%B8%A6%E4%B8%94%E6%88%91%E6%AD%A3%E5%9C%A8%E5%98%97%E8%A9%A6%E4%BD%BF%E7%94%A8%20for%20%E5%BE%AA%E7%92%B0%E4%BE%86%E7%B0%A1%E5%8C%96%E9%81%B8%E6%93%87%E8%BC%B8%E5%85%A5%E3%80%82%20%E4%BE%8B%E5%A6%82%EF%BC%8C%E6%88%91%E6%9C%89%E4%B8%80%E5%80%8B%E7%B5%84%E5%90%88%E6%A1%86%E5%92%8C%E4%B8%80%E5%80%8B%20collistbox%EF%BC%8C%E6%88%91%E6%AD%A3%E5%9C%A8%E5%98%97%E8%A9%A6%E4%BD%BF%E7%94%A8%E5%BE%AA%E7%92%B0%E8%AA%9E%E5%8F%A5%E7%8D%B2%E5%8F%96%E5%85%A9%E8%80%85%E7%9A%84%E8%BC%B8%E5%85%A5%E3%80%82%20%E4%BD%86%E6%98%AF%E7%95%B6%E6%88%91%E9%80%99%E6%A8%A3%E5%81%9A%E6%99%82%EF%BC%8C%E6%88%91%E5%BE%97%E5%88%B0%E4%BA%86%E4%B8%80%E5%80%8B%E9%8C%AF%E8%AA%A4%E3%80%82%20%E6%88%91%E5%AF%AB%E7%9A%84%E8%A1%A8%E9%81%94%E5%BC%8F%E4%B8%8D%E6%AD%A3%E7%A2%BA%E5%97%8E%EF%BC%9F%20%EF%BC%88%E9%99%84%E9%8C%AF%E8%AA%A4%E6%97%A5%E8%AA%8C%EF%BC%89%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(%201%20)%3B%0Adt%20%3D%20Open(%20%22%24SAMPLE_DATA%2FBig%20Class.jmp%22%20)%3B%0ANew%20Window(%20%22Col%20List%20Box%20Example%22%2C%0A%20vlistbox(%0A%20%20var1%20%3D%20combobox(%7B%22one%22%2C%20%22two%22%2C%20%22three%22%7D)%2C%0A%20%20hlistbox(Col%20List%20Box(%20all%2C%20width(%20250%20)%2C%20maxSelected(%201%20)%20)%2C%0A%20%20%20var2%20%3D%20Col%20List%20Box()%20%0A%20%20)%20%0A%20)%0A)%3B%0A%0Avar2%20%26lt%3B%26lt%3B%20append(%22height%22)%3B%0A%0AAA%20%3D%20%7B%22%22%2C%22%22%7D%3B%0A%0Afor(i%3D1%2Ci%26lt%3B%3D2%2Ci%2B%2B%2C%0A%20temp1%20%3D%20%22var%22%7C%7Cchar(i)%3B%0A%20eval(%0A%20%20substitute(%0A%20%20%20expr(try(AA%5Bi%5D%20%3D%20expr.temp1%20%26lt%3B%26lt%3B%20get%2C%20AA%5Bi%5D%20%3D%20expr.temp1%20%26lt%3B%26lt%3B%20get%20items))%2C%20%2F%2Ftry%20to%20use%20get%2C%20if%20error%2C%20use%20get%20items%0A%20%20%20expr(expr.temp1)%2Cparse(temp1)%0A%20%20)%0A%20)%0A)%3B%0A%0Ashow(AA)%3B%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-533192%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CLINGO-LABEL%3E%E8%85%B3%E6%9C%AC%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-533211%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3ERe%3A%20%E5%9C%A8%20Collistbox()%20%E4%B8%8A%E4%BD%BF%E7%94%A8%20Try()%20%E6%99%82%E5%87%BA%E9%8C%AF%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-533211%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%3E%3CP%3E%E6%88%91%E8%AA%8D%E7%82%BA%E6%82%A8%E7%9A%84%20Try%20%E4%B8%8D%E8%B5%B7%E4%BD%9C%E7%94%A8%EF%BC%8C%E5%9B%A0%E7%82%BA%20%26lt%3B%26lt%3B%20Get%20%E5%9C%A8%E8%88%87%20ListBoxBox%20%E4%B8%80%E8%B5%B7%E4%BD%BF%E7%94%A8%E6%99%82%E4%B8%8D%E6%9C%83%E5%87%BA%E7%8F%BE%E9%8C%AF%E8%AA%A4%EF%BC%88%E5%8F%AA%E6%98%AF%E8%A6%81%E8%A8%98%E9%8C%84%E7%9A%84%E6%B6%88%E6%81%AF%EF%BC%89%E3%80%82%20%E5%A6%82%E6%9E%9C%E6%82%A8%E6%83%B3%E4%BB%A5%E9%80%99%E7%A8%AE%E6%96%B9%E5%BC%8F%E7%8D%B2%E5%8F%96%E5%80%BC%EF%BC%8C%E4%BE%8B%E5%A6%82%E5%8F%AF%E4%BB%A5%E4%BD%BF%E7%94%A8%20%26lt%3B%26lt%3B%20%E9%A1%9E%E5%90%8D%EF%BC%9A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(1)%3B%0A%0Adt%20%3D%20Open(%22%24SAMPLE_DATA%2FBig%20Class.jmp%22)%3B%0ANew%20Window(%22Col%20List%20Box%20Example%22%2C%0A%20V%20List%20Box(%0A%20%20var1%20%3D%20Combo%20Box(%7B%22one%22%2C%20%22two%22%2C%20%22three%22%7D)%2C%0A%20%20H%20List%20Box(Col%20List%20Box(all%2C%20width(250)%2C%20maxSelected(1))%2C%20var2%20%3D%20Col%20List%20Box())%0A%20)%0A)%3B%0A%0Avar2%20%26lt%3B%26lt%3B%20append(%22height%22)%3B%0A%0AAA%20%3D%20%7B%22%22%2C%20%22%22%7D%3B%0AFor(i%20%3D%201%2C%20i%20%26lt%3B%3D%202%2C%20i%2B%2B%2C%0A%20temp1%20%3D%20%22var%22%20%7C%7C%20Char(i)%3B%0A%20Eval(%0A%20%20Substitute(%0A%20%20%20%20Expr(%0A%20%20%20%20%20If(expr.temp1%20%26lt%3B%26lt%3B%20class%20name%20%3D%3D%20%22ComboBox%22%2C%0A%20%20%20%20%20%20AA%5Bi%5D%20%3D%20expr.temp1%20%26lt%3B%26lt%3B%20get%0A%20%20%20%20%20%2C%0A%20%20%20%20%20%20AA%5Bi%5D%20%3D%20expr.temp1%20%26lt%3B%26lt%3B%20get%20items%20%20%20%20%20%0A%20%20%20%20%20)%0A%20%20%20%20)%2C%20%2F%2Ftry%20to%20use%20get%2C%20if%20error%2C%20use%20get%20items%0A%20%20%20Expr(expr.temp1)%2C%20Parse(temp1)%0A%20%20)%0A%20)%3B%0A)%3B%0A%0AShow(AA)%3B%20%2F%2FAA%20%3D%20%7B1%2C%20%7B%22height%22%7D%7D%3B%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%E6%88%91%E9%80%9A%E5%B8%B8%E5%BB%BA%E8%AD%B0%E4%B8%8D%E8%A6%81%E7%8D%B2%E5%8F%96%E9%80%99%E6%A8%A3%E7%9A%84%E5%80%BC%EF%BC%8C%E4%B8%A6%E5%98%97%E8%A9%A6%E4%BB%A5%E5%85%B6%E4%BB%96%E6%96%B9%E5%BC%8F%E8%80%8C%E4%B8%8D%E6%98%AF%E5%8B%95%E6%85%8B%E5%89%B5%E5%BB%BA%E8%AE%8A%E9%87%8F%E5%90%8D%EF%BC%88%E4%BE%8B%E5%A6%82%E5%AD%98%E5%84%B2%E5%B0%8D%E5%88%97%E8%A1%A8%E6%88%96%E9%97%9C%E8%81%AF%E6%95%B8%E7%B5%84%E7%9A%84%E5%BC%95%E7%94%A8%EF%BC%89%E3%80%82%3C%2FP%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
Djtjhin
Level IV

Error when using Try() on Collistbox()

Basically I'm building a custom interactive window which includes different display boxes and I'm trying to simplify the selection input with a for loop. For instance, I have both a combobox & a collistbox and I'm trying to get input for both using a loop statement. But when I did this, I got an error instead. Am I writing the expression incorrectly ? (error log attached)

 

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
New Window( "Col List Box Example",
	vlistbox(
		var1 = combobox({"one", "two", "three"}),
		hlistbox(Col List Box( all, width( 250 ), maxSelected( 1 ) ),
			var2 = Col List Box()	
		)	
	)
);

var2 << append("height");

AA = {"",""};

for(i=1,i<=2,i++,
	temp1 = "var"||char(i);
	eval(
		substitute(
			expr(try(AA[i] = expr.temp1 << get, AA[i] = expr.temp1 << get items)), //try to use get, if error, use get items
			expr(expr.temp1),parse(temp1)
		)
	)
);

show(AA);

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Error when using Try() on Collistbox()

I think your Try doesn't work because << Get doesn't rise an error when used with ListBoxBox (just a message to log). If you want to get values this way, you could for example use << Class Name:

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");
New Window("Col List Box Example",
	V List Box(
		var1 = Combo Box({"one", "two", "three"}),
		H List Box(Col List Box(all, width(250), maxSelected(1)), var2 = Col List Box())
	)
);

var2 << append("height");

AA = {"", ""};
For(i = 1, i <= 2, i++,
	temp1 = "var" || Char(i);
	Eval(
		Substitute(
				Expr(
					If(expr.temp1 << class name == "ComboBox",
						AA[i] = expr.temp1 << get
					,
						AA[i] = expr.temp1 << get items					
					)
				), //try to use get, if error, use get items
			Expr(expr.temp1), Parse(temp1)
		)
	);
);

Show(AA); //AA = {1, {"height"}};

 

I would usually suggest not getting the values like this and try to figure some other way than dynamically creating variable names (storing references to list or associative array for example).

-Jarmo

View solution in original post

1 REPLY 1
jthi
Super User

Re: Error when using Try() on Collistbox()

I think your Try doesn't work because << Get doesn't rise an error when used with ListBoxBox (just a message to log). If you want to get values this way, you could for example use << Class Name:

Names Default To Here(1);

dt = Open("$SAMPLE_DATA/Big Class.jmp");
New Window("Col List Box Example",
	V List Box(
		var1 = Combo Box({"one", "two", "three"}),
		H List Box(Col List Box(all, width(250), maxSelected(1)), var2 = Col List Box())
	)
);

var2 << append("height");

AA = {"", ""};
For(i = 1, i <= 2, i++,
	temp1 = "var" || Char(i);
	Eval(
		Substitute(
				Expr(
					If(expr.temp1 << class name == "ComboBox",
						AA[i] = expr.temp1 << get
					,
						AA[i] = expr.temp1 << get items					
					)
				), //try to use get, if error, use get items
			Expr(expr.temp1), Parse(temp1)
		)
	);
);

Show(AA); //AA = {1, {"height"}};

 

I would usually suggest not getting the values like this and try to figure some other way than dynamically creating variable names (storing references to list or associative array for example).

-Jarmo

Recommended Articles