cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
ALopez
Level III

Function fails to Return User input from Modal Window

The purpose of this code is to get User input to generate a report.  The User will select the Month and the type.  The code partially works as shown but as soon as I try to convert it to a function that resides on another JSL file (called with an "include") it fails. I am not able to get the two variables returned and I always get a "Name unresolved" error. I know that Month returns as a list and that the type returns as a string (?). What I am missing and how can I get the Month and the type returned by the function.
Thanks!

Names Default To Here( 1 );

monthLst = {"may", "June", "July"};

	nw = New Window( "Select Month",
		<<modal,
		Spacer Box( size( 25, 10 ) ),
		H List Box(
			V List Box(
				Text Box( Trim( "Please select Month and Type" ) ),
			
				Spacer Box( size( 10, 10 ) ),
				
				tb2 = List Box( "source", width( 300 ), nlines( 10 ), maxSelected( 1 ) ),
				tb2 << append( monthLst );
				Spacer Box( size( 10, 10 ) ),
				
				cb = Combo Box({"<Select type>","Accounting", "Financial"},

					),

				Spacer Box( size( 10, 10 ) ),
				
				H List Box(
					Align( left ),
					Spacer Box(),
					Button Box( "Cancel", bbCancelled = 1 ),
					Button Box( "OK",
						bbCancelled = 0;
						selectMo = tb2 << Get Selected;
						rcb = cb << Get Selected;	
					)
				)
				
			),
			Spacer Box( size( 50, 10 ) )
		), 
		
		Spacer Box( size( 25, 30 ) )
	
	);

	If( bbCancelled == 1,
		Stop(),
		If( selectMo == {}, 
			//error modal
			::dialogModalNoEdit( "Please select a Month." );
			
			//recursively call modal window function
			SelExpModal( monthLst );
		, 
			//if values were selected return results
			//Return(selectMo[1] ),

		)
	);
Print(selectMo);
Print(rcb);
1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Function fails to Return User input from Modal Window

If I understand correctly..

 

If you are creating a function you will have to return values you want to use after function has been executed (unless you want to use global variables).

 

In this case you could return them for example like this (associative array would maybe be better):

return(selectMo, rcb);

And in script that includes that script you can access them:

Names Default To Here(1);
Include("MonthTypeFunc.jsl");
retVal = MonthTypeWindow();
show(retVal[1],retVal[2]);

Attached example scripts. Place in the same folder and run Main.jsl.

-Jarmo

View solution in original post

2 REPLIES 2
jthi
Super User

Re: Function fails to Return User input from Modal Window

If I understand correctly..

 

If you are creating a function you will have to return values you want to use after function has been executed (unless you want to use global variables).

 

In this case you could return them for example like this (associative array would maybe be better):

return(selectMo, rcb);

And in script that includes that script you can access them:

Names Default To Here(1);
Include("MonthTypeFunc.jsl");
retVal = MonthTypeWindow();
show(retVal[1],retVal[2]);

Attached example scripts. Place in the same folder and run Main.jsl.

-Jarmo
ALopez
Level III

Re: Function fails to Return User input from Modal Window

Thank you very much jthi!  Never thought of using an associative array.