<?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: Nested for loop problem in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Nested-for-loop-problem/m-p/42413#M24658</link>
    <description>&lt;P&gt;You need to open the JMP log so you will see the errors. &amp;nbsp;I assumed the code you showed was psudo code, just showing the structure of how you wanted the code to work. &amp;nbsp;In JSL, you can not have a For loop without any arguments. &amp;nbsp;So I have adjusted the code I returned to you, so it will work&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names default to here(1);
colNames = List();
colNames[1] = "A";
colNames[2] = "B";
colNames[3] = "C";

dt = New Table( "new" );
Current Data Table( dt );

// Add Empty Rows to the Data Table
dt &amp;lt;&amp;lt; Add Rows( 4 );

For( col = 1, col &amp;lt;= 3, col++, 
 
	dt &amp;lt;&amp;lt; New Column( colNames[col] );
 
	For( row = 1, row &amp;lt;= 4, row++,    
    // Or you could conditionally add rows here
    // If( Col == 1, dt &amp;lt;&amp;lt; Add Rows( 1 ) );
    column(dt,ColNames[col])[row]=1;
	);

);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 22 Jul 2017 13:00:44 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2017-07-22T13:00:44Z</dc:date>
    <item>
      <title>Nested for loop problem</title>
      <link>https://community.jmp.com/t5/Discussions/Nested-for-loop-problem/m-p/42409#M24654</link>
      <description>&lt;P&gt;Hi, I am testing a nested for loop.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;col loop will create new columns&lt;/P&gt;&lt;P&gt;row loop will write in data for each row.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The inner row loop seems has problem, it created 1st col, but that is all.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;====================&lt;/P&gt;&lt;P&gt;colNames=list();&lt;BR /&gt;colNames[1]="A";&lt;BR /&gt;colNames[2]="B";&lt;BR /&gt;colNames[3]="C";&lt;BR /&gt;&lt;BR /&gt;dt = New Table("new");&lt;BR /&gt;Current Data Table(dt);&lt;BR /&gt;&lt;BR /&gt;for (col=1,col&amp;lt;=3,col++,&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;dt&amp;lt;&amp;lt;NewColumn(colNames[col]);&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;for(row=1,row&amp;lt;=4,row++,&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;//write data into eachrow&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;);&lt;BR /&gt;&lt;BR /&gt;);&lt;/P&gt;</description>
      <pubDate>Sat, 22 Jul 2017 09:30:24 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Nested-for-loop-problem/m-p/42409#M24654</guid>
      <dc:creator>Jay</dc:creator>
      <dc:date>2017-07-22T09:30:24Z</dc:date>
    </item>
    <item>
      <title>Re: Nested for loop problem</title>
      <link>https://community.jmp.com/t5/Discussions/Nested-for-loop-problem/m-p/42411#M24656</link>
      <description>&lt;P&gt;The issue is that in the flow of the script that you are using, you need to explicitly add rows to your data table, using the &amp;lt;&amp;lt; Add Rows() message. &amp;nbsp;See the code below for a couple of ways you could do it. &amp;nbsp;Also, the documentation for this is at:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Help==&amp;gt;Scripting Index==&amp;gt;Data Table==&amp;gt;Data Table Rows==&amp;gt;Add Rows&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names default to here(1);
colNames = List();
colNames[1] = "A";
colNames[2] = "B";
colNames[3] = "C";

dt = New Table( "new" );
Current Data Table( dt );

// Add Empty Rows to the Data Table
dt &amp;lt;&amp;lt; Add Rows( 4 );

For( col = 1, col &amp;lt;= 3, col++, 
 
	dt &amp;lt;&amp;lt; New Column( colNames[col] );
 
	For( row = 1, row &amp;lt;= 4, row++,    
    // Or you could conditionally add rows here
    // If( Col == 1, dt &amp;lt;&amp;lt; Add Rows( 1 ) );
	);

);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 22 Jul 2017 12:14:43 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Nested-for-loop-problem/m-p/42411#M24656</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2017-07-22T12:14:43Z</dc:date>
    </item>
    <item>
      <title>Re: Nested for loop problem</title>
      <link>https://community.jmp.com/t5/Discussions/Nested-for-loop-problem/m-p/42412#M24657</link>
      <description>Hi, Jim&lt;BR /&gt;Thanks for reply. I tried above, code, it still add in the column "A" only, and column "B" "C" is not there.</description>
      <pubDate>Sat, 22 Jul 2017 12:53:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Nested-for-loop-problem/m-p/42412#M24657</guid>
      <dc:creator>Jay</dc:creator>
      <dc:date>2017-07-22T12:53:12Z</dc:date>
    </item>
    <item>
      <title>Re: Nested for loop problem</title>
      <link>https://community.jmp.com/t5/Discussions/Nested-for-loop-problem/m-p/42413#M24658</link>
      <description>&lt;P&gt;You need to open the JMP log so you will see the errors. &amp;nbsp;I assumed the code you showed was psudo code, just showing the structure of how you wanted the code to work. &amp;nbsp;In JSL, you can not have a For loop without any arguments. &amp;nbsp;So I have adjusted the code I returned to you, so it will work&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names default to here(1);
colNames = List();
colNames[1] = "A";
colNames[2] = "B";
colNames[3] = "C";

dt = New Table( "new" );
Current Data Table( dt );

// Add Empty Rows to the Data Table
dt &amp;lt;&amp;lt; Add Rows( 4 );

For( col = 1, col &amp;lt;= 3, col++, 
 
	dt &amp;lt;&amp;lt; New Column( colNames[col] );
 
	For( row = 1, row &amp;lt;= 4, row++,    
    // Or you could conditionally add rows here
    // If( Col == 1, dt &amp;lt;&amp;lt; Add Rows( 1 ) );
    column(dt,ColNames[col])[row]=1;
	);

);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 22 Jul 2017 13:00:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Nested-for-loop-problem/m-p/42413#M24658</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2017-07-22T13:00:44Z</dc:date>
    </item>
    <item>
      <title>Re: Nested for loop problem</title>
      <link>https://community.jmp.com/t5/Discussions/Nested-for-loop-problem/m-p/42414#M24659</link>
      <description>Great. Thanks Jim. First project. Kind of difficult to get started.</description>
      <pubDate>Sat, 22 Jul 2017 13:05:39 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Nested-for-loop-problem/m-p/42414#M24659</guid>
      <dc:creator>Jay</dc:creator>
      <dc:date>2017-07-22T13:05:39Z</dc:date>
    </item>
    <item>
      <title>Re: Nested for loop problem</title>
      <link>https://community.jmp.com/t5/Discussions/Nested-for-loop-problem/m-p/42415#M24660</link>
      <description>&lt;P&gt;I strongly suggest you read or at least scan the Scripting Guide&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Help==&amp;gt;Books==&amp;gt;Scripting Guide&lt;/P&gt;</description>
      <pubDate>Sat, 22 Jul 2017 15:28:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Nested-for-loop-problem/m-p/42415#M24660</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2017-07-22T15:28:48Z</dc:date>
    </item>
  </channel>
</rss>

