<?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 Purposefully Raising Error in JSL in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Purposefully-Raising-Error-in-JSL/m-p/57789#M32157</link>
    <description>&lt;P&gt;I have been searching the forum and scripting index for a way to do this but have not found anything to accomplish what I am trying to do.&amp;nbsp; I am looking for something that has similar functionality to Python's "Raise" function.&amp;nbsp; Or essentially the same functionality as the Try Throw statements but without a JSL exception being raised.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example I am writing a function that requires the user to enter a date in the form of a string.&amp;nbsp; In order to prevent errors I want to check the input before using it in the function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Example Function = Function({start_date,end_date},
    chk1 = Is String(start_date);
    If(chk1 == 0, //Raise some error here);
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I think I could accomplish what I want with a Show("Error message") and Break() sequence but I am wondering if there is any native JSL methods to accomplish this task.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 21 May 2018 16:28:42 GMT</pubDate>
    <dc:creator>awsmagala</dc:creator>
    <dc:date>2018-05-21T16:28:42Z</dc:date>
    <item>
      <title>Purposefully Raising Error in JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Purposefully-Raising-Error-in-JSL/m-p/57789#M32157</link>
      <description>&lt;P&gt;I have been searching the forum and scripting index for a way to do this but have not found anything to accomplish what I am trying to do.&amp;nbsp; I am looking for something that has similar functionality to Python's "Raise" function.&amp;nbsp; Or essentially the same functionality as the Try Throw statements but without a JSL exception being raised.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For example I am writing a function that requires the user to enter a date in the form of a string.&amp;nbsp; In order to prevent errors I want to check the input before using it in the function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Example Function = Function({start_date,end_date},
    chk1 = Is String(start_date);
    If(chk1 == 0, //Raise some error here);
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I think I could accomplish what I want with a Show("Error message") and Break() sequence but I am wondering if there is any native JSL methods to accomplish this task.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 May 2018 16:28:42 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Purposefully-Raising-Error-in-JSL/m-p/57789#M32157</guid>
      <dc:creator>awsmagala</dc:creator>
      <dc:date>2018-05-21T16:28:42Z</dc:date>
    </item>
    <item>
      <title>Re: Purposefully Raising Error in JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Purposefully-Raising-Error-in-JSL/m-p/57791#M32159</link>
      <description>use the Try() function and then check on the results of it</description>
      <pubDate>Mon, 21 May 2018 16:40:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Purposefully-Raising-Error-in-JSL/m-p/57791#M32159</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2018-05-21T16:40:36Z</dc:date>
    </item>
    <item>
      <title>Re: Purposefully Raising Error in JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Purposefully-Raising-Error-in-JSL/m-p/57798#M32162</link>
      <description>&lt;P&gt;You can use &lt;A href="https://www.jmp.com/support/help/14/programming-functions.shtml#5022787" target="_blank"&gt;Throw()&lt;/A&gt; without a try. I think it's similar to Raise() in Python.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;//:*/
show("Here");
throw("This didn't work");
show("Here 2");
/*:

"Here";
This didn't work&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 May 2018 18:29:14 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Purposefully-Raising-Error-in-JSL/m-p/57798#M32162</guid>
      <dc:creator>Jeff_Perkinson</dc:creator>
      <dc:date>2018-05-21T18:29:14Z</dc:date>
    </item>
    <item>
      <title>Re: Purposefully Raising Error in JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Purposefully-Raising-Error-in-JSL/m-p/57801#M32165</link>
      <description>&lt;P&gt;I use a combination of a modal window to provide an error message for the user, and throw to terminate execution.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Example Date Check = Function({start_date,end_date},
    chk1 = Is String(start_date);
    If (!chk1 == 0,
		emsg = "Invalid start date [" || char(start_date) || "]";
		ew = new window("Invalid date", &amp;lt;&amp;lt; modal(),
			text box(emsg),
		);
		throw(emsg);
    );
    chk2 = Is String(end_date);
    If (!chk2 == 0,
		emsg = "Invalid end date [" || char(end_date) || "]";
		ew = new window("Invalid date", &amp;lt;&amp;lt; modal(),
			text box(emsg),
		);
		throw(emsg);
    );
);

example date check(today(), today());
example date check("31-Feb-2018", today());&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 21 May 2018 19:23:02 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Purposefully-Raising-Error-in-JSL/m-p/57801#M32165</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2018-05-21T19:23:02Z</dc:date>
    </item>
    <item>
      <title>Re: Purposefully Raising Error in JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Purposefully-Raising-Error-in-JSL/m-p/57807#M32167</link>
      <description>&lt;P&gt;You can use Throw to throw an error.&amp;nbsp; In the context of capturing user input errors you can use a modal window with an OnValidate message:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;NewWindow("Demo", &amp;lt;&amp;lt;Modal,
	&amp;lt;&amp;lt;OnValidate(
		n = teb &amp;lt;&amp;lt; Get;
		show(n);
		If (n&amp;lt;=100,
			isValid = 1;
			tbStatus &amp;lt;&amp;lt;SetText("")
		,
			isValid = 0;
			tbStatus &amp;lt;&amp;lt;SetText("try again!")
		);
		isValid
	),
	BorderBox(Top(20),Bottom(20),Left(20),Right(20),
		VListBox(
			HListBox(
				TextBox("Enter a number less than 100:  "),
				teb = NumberEditBox()
			),
			tbStatus = TextBox("",&amp;lt;&amp;lt;FontColor("red"))
		)
	)
);
show(n)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 May 2018 21:23:28 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Purposefully-Raising-Error-in-JSL/m-p/57807#M32167</guid>
      <dc:creator>David_Burnham</dc:creator>
      <dc:date>2018-05-21T21:23:28Z</dc:date>
    </item>
  </channel>
</rss>

