<?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: For Loop Issue When Iterating Through a List in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/For-Loop-Issue-When-Iterating-Through-a-List/m-p/35680#M21048</link>
    <description>&lt;P&gt;Did you try setting a break point in the Debugger and examining your variables through each iteration? That might give you some important clues.&lt;/P&gt;</description>
    <pubDate>Sat, 11 Feb 2017 12:39:14 GMT</pubDate>
    <dc:creator>Mark_Bailey</dc:creator>
    <dc:date>2017-02-11T12:39:14Z</dc:date>
    <item>
      <title>For Loop Issue When Iterating Through a List</title>
      <link>https://community.jmp.com/t5/Discussions/For-Loop-Issue-When-Iterating-Through-a-List/m-p/35679#M21047</link>
      <description>&lt;P&gt;I have a script that imports seal strength data and then uses that data to generate control charts. The data set has nearly a year's worth of data, but the control charts only need to display data from the last 3 months.&amp;nbsp;There is a list of active sealer numbers in the script and I had it set up to go through the list of active sealers and if there is data for that sealer in the last three months create a subset and then the control chart. It was working, but when I added in two new sealer numbers (11043 and 12143)&amp;nbsp;to the list recently the script won't generate the control charts for those two sealers. I have manually searched the data and know there is data for each of the two new sealers in the last three months. I can't figure out what is different for these two sealers that's causing the script to malfunction.&amp;nbsp;I attached some made up data in an excel file that is in the format we get from the seal strength testing. Here's what I have in the script:&lt;/P&gt;&lt;PRE&gt;//Import file and create data table&lt;BR /&gt;DS = Open("Source File Path Here"); //need to check where the file will be stored and what it will be called&lt;BR /&gt;DS &amp;lt;&amp;lt; Set Name ("Sealer Data - Maximum Load (lbf/in)");&lt;BR /&gt;&lt;BR /&gt;//Sort Data&lt;BR /&gt;DS &amp;lt;&amp;lt;Sort(By(:Sealer Number), Order(Ascending), Replace Table);&lt;BR /&gt;&lt;BR /&gt;//Modify date to display only the date and not the date and time&lt;BR /&gt;DS &amp;lt;&amp;lt; New Column("Date", Numeric, Continuous, Formula(Short Date(Num(Munger(Char(:End date), 1,10)))));&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;//Create a subset data table and control chart for each sealer&lt;BR /&gt;SL = {07056, 08139, 09066, 10083, 10088, 10532, 11043, 12035, 12036, 12093, 12119, 12143, 12144, 12145, 14122, 14123}; //list modified for 07Feb17 &lt;BR /&gt;&lt;BR /&gt;For(i=N Items(SL), i&amp;gt;0, i--, &lt;BR /&gt;DS &amp;lt;&amp;lt; Select Where (:Sealer Number == SL[i] &amp;amp; :Date &amp;gt;= Short Date(Today() - 90 * 86400));&lt;BR /&gt;If( N Row( DS &amp;lt;&amp;lt; get selected rows ) == 0, Continue() );&lt;BR /&gt;DS &amp;lt;&amp;lt; Subset ((Selected Rows), Output Table Name("Sealer_"||char(SL[i])));&lt;BR /&gt;IF(SL[i]==12119,&lt;BR /&gt;Control Chart(&lt;BR /&gt; Sample Label( :Date ),&lt;BR /&gt; Group Size( 1 ),&lt;BR /&gt; KSigma( 3 ),&lt;BR /&gt; Chart Col( :Maximum Load, Individual Measurement),&lt;BR /&gt; SendToReport(&lt;BR /&gt; Dispatch( {}, "Control Chart", OutlineBox, {Set Title( "Sealer_"||char(SL[i]) )} ),&lt;BR /&gt; Dispatch(&lt;BR /&gt; {"Individual Measurement of Maximum Load"},&lt;BR /&gt; "2",&lt;BR /&gt; ScaleBox,&lt;BR /&gt; {Format( "Fixed Dec", 12, 1 ), Min( -0.5), Max( 10 ), &lt;BR /&gt; Inc(5), Minor Ticks( 1 ),&lt;BR /&gt; Add Ref Line( 0.46, Dashed, "Purple", "0.46" ),&lt;BR /&gt; Add Ref Line( 0.7, Dotted, "Blue", "0.70" ),&lt;BR /&gt; Rotated Labels( "Horizontal" )}&lt;BR /&gt; ),&lt;BR /&gt; Dispatch(&lt;BR /&gt; {"Individual Measurement of Maximum Load"},&lt;BR /&gt; "1",&lt;BR /&gt; ScaleBox,&lt;BR /&gt; {Show Minor Ticks( 0 ), Rotated Labels( "Vertical" )}&lt;BR /&gt; ),&lt;BR /&gt; Dispatch(&lt;BR /&gt; {"Individual Measurement of Maximum Load"},&lt;BR /&gt; "",&lt;BR /&gt; AxisBox,&lt;BR /&gt; {Add Axis Label( "Maximum Load (lbf/in)" )}&lt;BR /&gt; ),&lt;BR /&gt; Dispatch(&lt;BR /&gt; {"Individual Measurement of Maximum Load"},&lt;BR /&gt; "IR Chart of IM",&lt;BR /&gt; FrameBox,&lt;BR /&gt; {Frame Size( 912, 318 ), Line Width Scale( 1.5 )}&lt;BR /&gt; ),&lt;BR /&gt; Dispatch(&lt;BR /&gt; {"Individual Measurement of Maximum Load"},&lt;BR /&gt; "",&lt;BR /&gt; AxisBox( 2 ),&lt;BR /&gt; {Add Axis Label( "Date" )}&lt;BR /&gt; ),&lt;BR /&gt; Dispatch(&lt;BR /&gt; {"Individual Measurement of Maximum Load"},&lt;BR /&gt; "IR Chart of IM",&lt;BR /&gt; FrameBox( 2 ),&lt;BR /&gt; {Frame Size( 70, 318 )}&lt;BR /&gt; ),&lt;BR /&gt; Dispatch(&lt;BR /&gt; {"Individual Measurement of Maximum Load"},&lt;BR /&gt; "1",&lt;BR /&gt; ScaleBox,&lt;BR /&gt; {Inc( 1 ), Minor Ticks( 0 )}&lt;BR /&gt; )&lt;BR /&gt; &lt;BR /&gt; ), &lt;BR /&gt;), &lt;BR /&gt;Control Chart(&lt;BR /&gt; Sample Label( :Date ),&lt;BR /&gt; Group Size( 1 ),&lt;BR /&gt; KSigma( 3 ),&lt;BR /&gt; Chart Col( :Maximum Load, Individual Measurement),&lt;BR /&gt; SendToReport(&lt;BR /&gt; Dispatch( {}, "Control Chart", OutlineBox, {Set Title( "Sealer_"||char(SL[i]) )} ),&lt;BR /&gt; Dispatch(&lt;BR /&gt; {"Individual Measurement of Maximum Load"},&lt;BR /&gt; "2",&lt;BR /&gt; ScaleBox,&lt;BR /&gt; {Format( "Fixed Dec", 12, 1 ), Min( -0.5 ), Max( 5 ), &lt;BR /&gt; Inc( 5 ), Minor Ticks( 1 ), Add Ref Line( 0.46, "Dashed", "Purple", "0.46", 1 ),&lt;BR /&gt; Add Ref Line( 0.7, "Dotted", "Blue", "0.70", 1 )}&lt;BR /&gt; ),&lt;BR /&gt; Dispatch(&lt;BR /&gt; {"Individual Measurement of Maximum Load"},&lt;BR /&gt; "1",&lt;BR /&gt; ScaleBox,&lt;BR /&gt; {Inc( 1 ), Minor Ticks( 0 )}&lt;BR /&gt; ),&lt;BR /&gt; Dispatch(&lt;BR /&gt; {"Individual Measurement of Maximum Load"},&lt;BR /&gt; "",&lt;BR /&gt; AxisBox,&lt;BR /&gt; {Add Axis Label( "Maximum Load (lbf/in)" )}&lt;BR /&gt; ),&lt;BR /&gt; Dispatch(&lt;BR /&gt; {"Individual Measurement of Maximum Load"},&lt;BR /&gt; "IR Chart of IM",&lt;BR /&gt; FrameBox,&lt;BR /&gt; {Frame Size( 912, 318 ), Line Width Scale( 1.5 )}&lt;BR /&gt; ),&lt;BR /&gt; Dispatch(&lt;BR /&gt; {"Individual Measurement of Maximum Load"},&lt;BR /&gt; "",&lt;BR /&gt; AxisBox( 2 ),&lt;BR /&gt; {Add Axis Label( "Date" )}&lt;BR /&gt; ),&lt;BR /&gt; Dispatch(&lt;BR /&gt; {"Individual Measurement of Maximum Load"},&lt;BR /&gt; "IR Chart of IM",&lt;BR /&gt; FrameBox( 2 ),&lt;BR /&gt; {Frame Size( 70, 318 )}&lt;BR /&gt; )&lt;BR /&gt; &lt;BR /&gt; )&lt;BR /&gt;); &lt;BR /&gt;); &lt;BR /&gt;);&lt;/PRE&gt;&lt;P&gt;t and I had it set up to go through the list of active sealers and if there is data for that sealer in the last three months create a subset and then the control chart. It was working, but when I added in two new sealer numbers to the list recently the script won't generate the control charts for those two sealers. I have manually searched the data and know there is data for each of the two new sealers in the last three months. I can't figure out what is different for these two sealers that's causing the script to malfunction.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 11 Feb 2017 05:04:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/For-Loop-Issue-When-Iterating-Through-a-List/m-p/35679#M21047</guid>
      <dc:creator>rfeick</dc:creator>
      <dc:date>2017-02-11T05:04:34Z</dc:date>
    </item>
    <item>
      <title>Re: For Loop Issue When Iterating Through a List</title>
      <link>https://community.jmp.com/t5/Discussions/For-Loop-Issue-When-Iterating-Through-a-List/m-p/35680#M21048</link>
      <description>&lt;P&gt;Did you try setting a break point in the Debugger and examining your variables through each iteration? That might give you some important clues.&lt;/P&gt;</description>
      <pubDate>Sat, 11 Feb 2017 12:39:14 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/For-Loop-Issue-When-Iterating-Through-a-List/m-p/35680#M21048</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2017-02-11T12:39:14Z</dc:date>
    </item>
    <item>
      <title>Re: For Loop Issue When Iterating Through a List</title>
      <link>https://community.jmp.com/t5/Discussions/For-Loop-Issue-When-Iterating-Through-a-List/m-p/35682#M21050</link>
      <description>&lt;P&gt;I'd suspect this code is falling into the continue case:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;    DS &amp;lt;&amp;lt; Select Where( :Sealer Number == SL[i] &amp;amp; :Date &amp;gt;= Short Date( Today() - 90 * 86400 ) );
    If( N Row( DS &amp;lt;&amp;lt; get selected rows ) == 0,
        Continue()
    );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;As Mark suggests, set a breakpoint on the continue, or maybe just add a statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Show( i, SL[i], :Date );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Look in the log for the output. I'll make a guess that :Date is going to be wrong, perhaps because there is no current row in the data table.&lt;/P&gt;</description>
      <pubDate>Sat, 11 Feb 2017 13:57:59 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/For-Loop-Issue-When-Iterating-Through-a-List/m-p/35682#M21050</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2017-02-11T13:57:59Z</dc:date>
    </item>
    <item>
      <title>Re: For Loop Issue When Iterating Through a List</title>
      <link>https://community.jmp.com/t5/Discussions/For-Loop-Issue-When-Iterating-Through-a-List/m-p/35848#M21148</link>
      <description>&lt;P&gt;Thanks for the help! Once I changed&lt;/P&gt;&lt;P&gt;&lt;FONT face="Consolas" size="2"&gt;:Date &amp;gt;= &lt;/FONT&gt;&lt;FONT color="#0000dd" face="Consolas" size="2"&gt;Short Date&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;(&lt;/FONT&gt;&lt;FONT color="#0000dd" face="Consolas" size="2"&gt;Today&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;() - &lt;/FONT&gt;&lt;FONT color="#008080" face="Consolas" size="2"&gt;90&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt; * &lt;/FONT&gt;&lt;FONT color="#008080" face="Consolas" size="2"&gt;86400&lt;/FONT&gt; to&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000dd" face="Consolas" size="2"&gt;Num&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;(:Date) &amp;gt;= &lt;/FONT&gt;&lt;FONT color="#0000dd" face="Consolas" size="2"&gt;Today&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;() - &lt;/FONT&gt;&lt;FONT color="#008080" face="Consolas" size="2"&gt;90&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt; * &lt;/FONT&gt;&lt;FONT color="#008080" face="Consolas" size="2"&gt;86400&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;the script ran correctly. I think it was something with the Date column being changed to a character column rather than a numeric column which it was supposed to be.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2017 20:12:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/For-Loop-Issue-When-Iterating-Through-a-List/m-p/35848#M21148</guid>
      <dc:creator>rfeick</dc:creator>
      <dc:date>2017-02-15T20:12:09Z</dc:date>
    </item>
  </channel>
</rss>

