<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Problem With User Input as Variable in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Problem-With-User-Input-as-Variable/m-p/34759#M20526</link>
    <description>&lt;P&gt;Thanks, that was very helpful! Keeping the date numeric makes a lot of sense and requires less converting.&lt;/P&gt;</description>
    <pubDate>Thu, 19 Jan 2017 20:41:07 GMT</pubDate>
    <dc:creator>Aaron_Wooley</dc:creator>
    <dc:date>2017-01-19T20:41:07Z</dc:date>
    <item>
      <title>Problem With User Input as Variable</title>
      <link>https://community.jmp.com/t5/Discussions/Problem-With-User-Input-as-Variable/m-p/34707#M20493</link>
      <description>&lt;P&gt;I am running into a problem with getting user input and turning it into a variable. The script that I am attempting to use for this is pasted below this paragraph. I have run the same script multiple times and without editing it, I get two different results in the log. This script is as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;names default to here(1);
clear log();
close all(journals, no save);
close all(data tables, no save);
 
 
defuplim = format(today(),"ddMonyyyy");
deflowlim = format(today() - in days(730), "ddMonyyyy");
 
New Window("Pick Your Dates in ddMonyyyy format",
       &amp;lt;&amp;lt;Modal,
       &amp;lt;&amp;lt;return result,
       V List Box(
              Text Box("Start Date:"),
              str1=Text Edit Box(deflowlim),
              text box("End Date:"),
              str2=Text Edit Box(defuplim)
       ),
       H List Box (Button Box ("OK"), Button Box ("Cancel"))
);
 
lowlim = str1 &amp;lt;&amp;lt; get text;
uplim = str2 &amp;lt;&amp;lt; get text;
 
 
lowlim=informat(lowlim);
uplim= informat(uplim);
 
show (lowlim);
show (uplim);
 &lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The first result from the log is what I expect the script to produce and is copied and pasted in quotes below:&lt;/P&gt;&lt;P&gt;“&lt;/P&gt;&lt;P&gt;lowlim = 19Jan2015;&lt;/P&gt;&lt;P&gt;uplim = 18Jan2017;&lt;/P&gt;&lt;P&gt;“&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The other response I get from the log (again, without editing the script at all) is this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;“&lt;/P&gt;&lt;P&gt;deleted object reference: str2 &amp;lt;&amp;lt; get text in access or evaluation of 'Glue' , Names Default To Here( 1 ); /*###*/Clear Log(); /*###*/&lt;/P&gt;&lt;P&gt;Close All( journals, no save ); /*###*/Close All( data tables, no save ); /*###*/&lt;/P&gt;&lt;P&gt;defuplim = Format( Today(), "ddMonyyyy" ); /*###*/deflowlim =&lt;/P&gt;&lt;P&gt;Format( Today() - In Days( 730 ), "ddMonyyyy" ); /*###*/&lt;/P&gt;&lt;P&gt;New Window( "Pick Your Dates in ddMonyyyy format",&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&amp;lt;Modal,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&amp;lt;return result,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; V List Box(&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Text Box( "Start Date:" ),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; str1 = Text Edit Box( deflowlim ),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Text Box( "End Date:" ),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; str2 = Text Edit Box( defuplim )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; H List Box( Button Box( "OK" ), Button Box( "Cancel" ) )&lt;/P&gt;&lt;P&gt;); /*###*/lowlim = str1 &amp;lt;&amp;lt; get text; /*###*/uplim = str2 &amp;lt;&amp;lt; get text; /*###*/lowlim&lt;/P&gt;&lt;P&gt;&amp;nbsp;= Informat( lowlim ); /*###*/uplim = Informat( uplim ); /*###*/Show( lowlim ); /*###*/&lt;/P&gt;&lt;P&gt;Show( uplim ) /*###*/;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the following script, error marked by /*###*/&lt;/P&gt;&lt;P&gt;Names Default To Here( 1 ); /*###*/Clear Log(); /*###*/&lt;/P&gt;&lt;P&gt;Close All( journals, no save ); /*###*/Close All( data tables, no save ); /*###*/&lt;/P&gt;&lt;P&gt;defuplim = Format( Today(), "ddMonyyyy" ); /*###*/deflowlim =&lt;/P&gt;&lt;P&gt;Format( Today() - In Days( 730 ), "ddMonyyyy" ); /*###*/&lt;/P&gt;&lt;P&gt;New Window( "Pick Your Dates in ddMonyyyy format",&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&amp;lt;Modal,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&amp;lt;return result,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; V List Box(&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Text Box( "Start Date:" ),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; str1 = Text Edit Box( deflowlim ),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Text Box( "End Date:" ),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; str2 = Text Edit Box( defuplim )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ),&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; H List Box( Button Box( "OK" ), Button Box( "Cancel" ) )&lt;/P&gt;&lt;P&gt;); /*###*/lowlim = str1 &amp;lt;&amp;lt; get text; /*###*/uplim = str2 &amp;lt;&amp;lt; get text; /*###*/lowlim&lt;/P&gt;&lt;P&gt;&amp;nbsp;= Informat( lowlim ); /*###*/uplim = Informat( uplim ); /*###*/Show( lowlim ); /*###*/&lt;/P&gt;&lt;P&gt;Show( uplim ) /*###*/;&lt;/P&gt;&lt;P&gt;“&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I’ve toggled off and on the first four lines, but get the same results (a mix of responses) regardless of whether or not they are turned off or on.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas what may be causing this error?&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jan 2017 21:57:42 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Problem-With-User-Input-as-Variable/m-p/34707#M20493</guid>
      <dc:creator>Aaron_Wooley</dc:creator>
      <dc:date>2017-01-18T21:57:42Z</dc:date>
    </item>
    <item>
      <title>Re: Problem With User Input as Variable</title>
      <link>https://community.jmp.com/t5/Discussions/Problem-With-User-Input-as-Variable/m-p/34714#M20500</link>
      <description>&lt;P&gt;Try this version....it keeps the date as a numeric which is the way that JMP prefers to handle them&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
Clear Log();
Close All( journals, no save );
Close All( data tables, no save );
 
 
defuplim = Today();
deflowlim = Today() - In Days( 730 );
 
New Window( "Pick Your Dates in ddMonyyyy format",
	&amp;lt;&amp;lt;Modal,
	&amp;lt;&amp;lt;return result,
	V List Box(
		Text Box( "Start Date:" ),
		str1 = Number Edit Box(
			deflowlim,
			10,
			&amp;lt;&amp;lt;SetFunction(
				Function( {that}, 
					lowlim = str1 &amp;lt;&amp;lt; get
				)
			)
		),
		Text Box( "End Date:" ),
		str2 = Number Edit Box(
			defuplim,
			10,
			&amp;lt;&amp;lt;SetFunction(
				Function( {this}, 
					uplim = str2 &amp;lt;&amp;lt; get
				),

			)
		),
		str1 &amp;lt;&amp;lt; set format( Format( "ddMonyyyy" ) ),
		str2 &amp;lt;&amp;lt; set format( Format( "ddMonyyyy" ) )
	),
	H List Box( Button Box( "OK" ), Button Box( "Cancel" ) ), 
       
);

 
Show( Format( lowlim, "ddMonyyyy" ) );
Show( Format( uplim, "ddMonyyyy" ) );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 19 Jan 2017 01:38:47 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Problem-With-User-Input-as-Variable/m-p/34714#M20500</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2017-01-19T01:38:47Z</dc:date>
    </item>
    <item>
      <title>Re: Problem With User Input as Variable</title>
      <link>https://community.jmp.com/t5/Discussions/Problem-With-User-Input-as-Variable/m-p/34726#M20507</link>
      <description>&lt;P&gt;txnelson's script is a better way to handle dates, plus it also solves the core problem you're having with your script by doing the getting values within the boxes.&lt;BR /&gt; &lt;BR /&gt;In your script, you create a modal new window, but then try to get information out of display boxes in the window after it's closed. Once a window is closed, you can't access what it held anymore - it doesn't exist anymore. This is why you're getting syntax errors for lowlim = str1 &amp;lt;&amp;lt; get text;&lt;BR /&gt; &lt;BR /&gt;You're almost there, though - you specified return result for the modal window, but you're not using what you're getting from it.&lt;BR /&gt; &lt;BR /&gt;Without making any other changes (though txnelson's date handling is better), you can get what you want by assigning the New Window to a variable, and then getting those values&amp;nbsp;(changes below in red):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;FONT color="#FF0000"&gt;ww =&lt;/FONT&gt; New Window("Pick Your Dates in ddMonyyyy format",
       &amp;lt;&amp;lt;Modal,
       &amp;lt;&amp;lt;return result,
       V List Box(
              Text Box("Start Date:"),
              str1=Text Edit Box(deflowlim),
              text box("End Date:"),
              str2=Text Edit Box(defuplim)
       ),
       H List Box (Button Box ("OK"), Button Box ("Cancel"))
);
 
lowlim =&amp;nbsp;&lt;FONT color="#FF0000"&gt;ww["str1"]&lt;/FONT&gt;;
uplim =&amp;nbsp;&lt;FONT color="#FF0000"&gt;ww["str2"]&lt;/FONT&gt;;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2017 15:15:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Problem-With-User-Input-as-Variable/m-p/34726#M20507</guid>
      <dc:creator>Melanie_J_Drake</dc:creator>
      <dc:date>2017-01-19T15:15:18Z</dc:date>
    </item>
    <item>
      <title>Re: Problem With User Input as Variable</title>
      <link>https://community.jmp.com/t5/Discussions/Problem-With-User-Input-as-Variable/m-p/34759#M20526</link>
      <description>&lt;P&gt;Thanks, that was very helpful! Keeping the date numeric makes a lot of sense and requires less converting.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jan 2017 20:41:07 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Problem-With-User-Input-as-Variable/m-p/34759#M20526</guid>
      <dc:creator>Aaron_Wooley</dc:creator>
      <dc:date>2017-01-19T20:41:07Z</dc:date>
    </item>
    <item>
      <title>Re: Problem With User Input as Variable</title>
      <link>https://community.jmp.com/t5/Discussions/Problem-With-User-Input-as-Variable/m-p/330788#M57989</link>
      <description>&lt;P&gt;New to jmp and trying to understand how this sequence works - could someone explain how this aspect of the code works? Looks like it saves the box input to a local variable without needing to output text box results to an array, but unsure how the function works to accomplish this.&amp;nbsp;&lt;/P&gt;&lt;PRE class="language-jsl"&gt;&lt;CODE&gt;&amp;lt;&amp;lt;SetFunction(
				Function( {that}, 
					lowlim = str1 &amp;lt;&amp;lt; get
				)
			)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 07 Nov 2020 08:00:46 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Problem-With-User-Input-as-Variable/m-p/330788#M57989</guid>
      <dc:creator>TFranke</dc:creator>
      <dc:date>2020-11-07T08:00:46Z</dc:date>
    </item>
    <item>
      <title>Re: Problem With User Input as Variable</title>
      <link>https://community.jmp.com/t5/Discussions/Problem-With-User-Input-as-Variable/m-p/330793#M57990</link>
      <description>&lt;P&gt;One needs to look at more of the code than what you specified, in order to interpret it&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;deflowlim = Today() - In Days( 730 );

str1 = Number Edit Box(
	deflowlim,
	10,
	&amp;lt;&amp;lt;SetFunction(
		Function( {that}, 
			lowlim = str1 &amp;lt;&amp;lt; get
		)
	)
)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What is basically going on here, is setting up a data entry field to allow the user to enter a date.&amp;nbsp; The type of data entry field is a Number Edit Box(). (See documentation and example of Number Edit Box() in the Scripting Index under the Help pull down menu).&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="neb1.PNG" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/28171i050CE786CC34B0D1/image-size/large?v=v2&amp;amp;px=999" role="button" title="neb1.PNG" alt="neb1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The documentation states that form of the Number Edit Box() is:&lt;/P&gt;
&lt;PRE&gt;y = Number Edit Box( initValue, &amp;lt;width&amp;gt; )&lt;/PRE&gt;
&lt;P&gt;A variable called "str1" is assigned as a pointer to the Number Edit Box(). In the illustration, this is the "y" variable&lt;/P&gt;
&lt;P&gt;The variable, "deflowlim" is used to set the initial value to be displayed in the Number Edit Box(). In the illustration, this is the "initValue".&lt;/P&gt;
&lt;P&gt;The width of the Number Edit Box() is set to 10 characters&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As can be seen in the above documentation listing, there are a large number of Item Messages that can be passed to the Number Edit Box() object.&amp;nbsp; The message in question from the code you are asking about, is "Set Function".&amp;nbsp; Here is the listing from the Scripting Index&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="neb2.PNG" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/28172i52AFB6A9577A2E67/image-size/large?v=v2&amp;amp;px=999" role="button" title="neb2.PNG" alt="neb2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;What this message does, is to set up a piece of JSL that is run whenever something is changed in the Number Edit Box().&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;lowlim = str1 &amp;lt;&amp;lt; get&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So every time, something is changed in the Number Edit Box(), a "get" message is passed to "str1", which is the Number Edit Box()&lt;/P&gt;
&lt;P&gt;The "get" message is:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="neb3.PNG" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/28173iDA7A58A2EBA7F7F5/image-size/large?v=v2&amp;amp;px=999" role="button" title="neb3.PNG" alt="neb3.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;Returns the number currently entered in the edit box&lt;/PRE&gt;
&lt;P&gt;and the returned number is assigned to the variable "lowlim".&lt;/P&gt;
&lt;P&gt;Therefore, "lowlim" is a scalar variable, which can be referenced in subsequent JSL.&amp;nbsp; Only a scalar variable needs to be assigned, since JMP dates are stored as a continuous numeric data value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope this clears up your question(s).&lt;/P&gt;</description>
      <pubDate>Sat, 07 Nov 2020 10:11:49 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Problem-With-User-Input-as-Variable/m-p/330793#M57990</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-11-07T10:11:49Z</dc:date>
    </item>
    <item>
      <title>Re: Problem With User Input as Variable</title>
      <link>https://community.jmp.com/t5/Discussions/Problem-With-User-Input-as-Variable/m-p/330794#M57991</link>
      <description>Got it, that explains why removing the Set Function caused variables to be stored as null. Without the Set function it doesn't update with each change made to the edit box. Thank you for the thorough explanation!</description>
      <pubDate>Sat, 07 Nov 2020 10:37:47 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Problem-With-User-Input-as-Variable/m-p/330794#M57991</guid>
      <dc:creator>TFranke</dc:creator>
      <dc:date>2020-11-07T10:37:47Z</dc:date>
    </item>
  </channel>
</rss>

