<?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 Is it possible to iterate through all elements in an associative array? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Is-it-possible-to-iterate-through-all-elements-in-an-associative/m-p/53105#M30060</link>
    <description>&lt;P&gt;I would like to use a&amp;nbsp;loop to iterate through all values in an associative array.&amp;nbsp; &amp;nbsp;For the life of me, I cannot find the interator function for associative arrays. Is it simply impossible to step through all values in an associative array if they are not at pre-known keys?!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In my associative array, the keys are strings and the values are lists.&amp;nbsp; I need to iterate through the entire associative array, and for each key, read something from the value.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;This is my (incomplete) script.&amp;nbsp;&amp;nbsp;I am a semi-veteran of some programming languages but I am a noob at JMP script.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Where I put comments inside /*&amp;nbsp; */ is where there is code that I don't know how to do.&amp;nbsp; I am stuck at /*For all parts in lastTests*/ near the bottom, though I don't know if the rest of my script works because I haven't tried running any of it yet.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By the way, the JMP scripting guide has a very brief section on associative arrays and it does not tell you how to iterate through elements within an associative array :(&lt;/img&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please help!&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Current Data Table();


lastTests = Associative Array();


For Each Row (
 
 partKey = Char(:Name("214:ReadOTP:OTP_Row_40[1]") + 256*:Name("215:ReadOTP:OTP_Row_41[1]") + 256*256*:Name("223:ReadOTP:OTP_Row_49[1]") + 256*256*256*:Name("224:ReadOTP:OTP_Row_4a[1]") + 256*256*256*256*:Name("123:LOG_SETPOINT_SPEA:SPEA_Setpoint[1]"));
 
 rowValue = {:Name("start_t"), :Name("part_id"), Row()};
 
 If (Is List(lastTests[partKey]) == 1,
 If ( rowValue[1] &amp;gt; lastTests[partKey][1], //if start_t is later
 lastTests[partKey] = rowValue,
 
 //else if
 (rowValue[1] == lastTests[partKey][1]) &amp;amp; (rowValue[2] &amp;gt; lastTests[partKey][2]), //if start_t is the same but part_id is larger
 lastTests[partKey] = rowValue;
 
 
 ),
 //else
 lastTests[partKey] = rowValue;
 
 );
 
 
);

listOfRowsToSelect = {};

/*For all parts in lastTests*/(
 selectedPart = /*get present item*/;
 Insert Into(listOfRowsToSelect, selectedPart[3]);

);

dt &amp;lt;&amp;lt; Select Rows( listOfRowsToSelect );

/*Invert Selection*/;

/*Hide and Exclude selected rows*/;

dt &amp;lt;&amp;lt; Clear Select;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 14 Mar 2018 10:51:38 GMT</pubDate>
    <dc:creator>tatarjj</dc:creator>
    <dc:date>2018-03-14T10:51:38Z</dc:date>
    <item>
      <title>Is it possible to iterate through all elements in an associative array?</title>
      <link>https://community.jmp.com/t5/Discussions/Is-it-possible-to-iterate-through-all-elements-in-an-associative/m-p/53105#M30060</link>
      <description>&lt;P&gt;I would like to use a&amp;nbsp;loop to iterate through all values in an associative array.&amp;nbsp; &amp;nbsp;For the life of me, I cannot find the interator function for associative arrays. Is it simply impossible to step through all values in an associative array if they are not at pre-known keys?!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In my associative array, the keys are strings and the values are lists.&amp;nbsp; I need to iterate through the entire associative array, and for each key, read something from the value.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;This is my (incomplete) script.&amp;nbsp;&amp;nbsp;I am a semi-veteran of some programming languages but I am a noob at JMP script.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Where I put comments inside /*&amp;nbsp; */ is where there is code that I don't know how to do.&amp;nbsp; I am stuck at /*For all parts in lastTests*/ near the bottom, though I don't know if the rest of my script works because I haven't tried running any of it yet.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By the way, the JMP scripting guide has a very brief section on associative arrays and it does not tell you how to iterate through elements within an associative array :(&lt;/img&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please help!&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Current Data Table();


lastTests = Associative Array();


For Each Row (
 
 partKey = Char(:Name("214:ReadOTP:OTP_Row_40[1]") + 256*:Name("215:ReadOTP:OTP_Row_41[1]") + 256*256*:Name("223:ReadOTP:OTP_Row_49[1]") + 256*256*256*:Name("224:ReadOTP:OTP_Row_4a[1]") + 256*256*256*256*:Name("123:LOG_SETPOINT_SPEA:SPEA_Setpoint[1]"));
 
 rowValue = {:Name("start_t"), :Name("part_id"), Row()};
 
 If (Is List(lastTests[partKey]) == 1,
 If ( rowValue[1] &amp;gt; lastTests[partKey][1], //if start_t is later
 lastTests[partKey] = rowValue,
 
 //else if
 (rowValue[1] == lastTests[partKey][1]) &amp;amp; (rowValue[2] &amp;gt; lastTests[partKey][2]), //if start_t is the same but part_id is larger
 lastTests[partKey] = rowValue;
 
 
 ),
 //else
 lastTests[partKey] = rowValue;
 
 );
 
 
);

listOfRowsToSelect = {};

/*For all parts in lastTests*/(
 selectedPart = /*get present item*/;
 Insert Into(listOfRowsToSelect, selectedPart[3]);

);

dt &amp;lt;&amp;lt; Select Rows( listOfRowsToSelect );

/*Invert Selection*/;

/*Hide and Exclude selected rows*/;

dt &amp;lt;&amp;lt; Clear Select;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 10:51:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Is-it-possible-to-iterate-through-all-elements-in-an-associative/m-p/53105#M30060</guid>
      <dc:creator>tatarjj</dc:creator>
      <dc:date>2018-03-14T10:51:38Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to iterate through all elements in an associative array?</title>
      <link>https://community.jmp.com/t5/Discussions/Is-it-possible-to-iterate-through-all-elements-in-an-associative/m-p/53106#M30061</link>
      <description>&lt;P&gt;As an example, this is how you iterate through all values in a table (named "t") in Lua, a common scripting language:&lt;/P&gt;&lt;P&gt;for key, val in pairs (t) do&lt;/P&gt;&lt;P&gt;&amp;lt;stuff&amp;gt;&lt;/P&gt;&lt;P&gt;end&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What is the equivalent in JMP scripting language for associative arrays?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 06:05:55 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Is-it-possible-to-iterate-through-all-elements-in-an-associative/m-p/53106#M30061</guid>
      <dc:creator>tatarjj</dc:creator>
      <dc:date>2018-03-14T06:05:55Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to iterate through all elements in an associative array?</title>
      <link>https://community.jmp.com/t5/Discussions/Is-it-possible-to-iterate-through-all-elements-in-an-associative/m-p/53111#M30064</link>
      <description>&lt;P&gt;To find the functions and messages available to an Associative Array, go to&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Help==&amp;gt;Scripting Index==&amp;gt;Associative Array&lt;/P&gt;
&lt;P&gt;There you will find several ways of looping through the keys, or values by retrieving them into a list and then using a For() loop, etc.&amp;nbsp; Below is an example taken directly from the examples given in the Scripting Index using "First" and "Next" to loop through an Associative Array&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
Local(
	{aa = [1 =&amp;gt; "bun",
	2 =&amp;gt; "shoe",
	3 =&amp;gt; "tree",
	4 =&amp;gt; "door"], x, words = ""},
	x = aa &amp;lt;&amp;lt; First;
	While( !Is Empty( x ),
		words = words || aa[x];
		x = aa &amp;lt;&amp;lt; Next( x );
	);
	words;
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Also, starting on Page 207 in the JSL Scripting Guide there are several pages of documentation on how to Create and Use Associative Arrays in JMP&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>Wed, 14 Mar 2018 09:17:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Is-it-possible-to-iterate-through-all-elements-in-an-associative/m-p/53111#M30064</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2018-03-14T09:17:58Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to iterate through all elements in an associative array?</title>
      <link>https://community.jmp.com/t5/Discussions/Is-it-possible-to-iterate-through-all-elements-in-an-associative/m-p/53122#M30069</link>
      <description>&lt;P&gt;Thank you!&amp;nbsp; I did not know about the Help-&amp;gt;Scripting Index!&lt;/P&gt;&lt;P&gt;It looks like in my case, I need to use the Get Values function (I don't need the keys).&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 15:59:33 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Is-it-possible-to-iterate-through-all-elements-in-an-associative/m-p/53122#M30069</guid>
      <dc:creator>tatarjj</dc:creator>
      <dc:date>2018-03-14T15:59:33Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to iterate through all elements in an associative array?</title>
      <link>https://community.jmp.com/t5/Discussions/Is-it-possible-to-iterate-through-all-elements-in-an-associative/m-p/53133#M30075</link>
      <description>&lt;P&gt;Be aware that there is no ordering of the contents of the associative array. Indexing is out. That is&amp;nbsp;the reason for the First and Next messages to iterate over the array. Using the Get Values message returns an ordered result, but the contents are not necessarily in this order.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 17:34:31 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Is-it-possible-to-iterate-through-all-elements-in-an-associative/m-p/53133#M30075</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2018-03-14T17:34:31Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to iterate through all elements in an associative array?</title>
      <link>https://community.jmp.com/t5/Discussions/Is-it-possible-to-iterate-through-all-elements-in-an-associative/m-p/53139#M30079</link>
      <description>&lt;P&gt;Thanks Mark, IMO, this is how it should operate and it's the same as how similar data structures in other languages operate.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How does one test if an associative array has a value assigned to specific key? Since I am assigning specific "Char" (the same as string?) key values to lists, I first tried the Is List function, but it gave me an error. This was my script:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Current Data Table();


lastTests = Associative Array();


For Each Row (
	
	partKey = Char(:Name("214:ReadOTP:OTP_Row_40[1]") + 256*:Name("215:ReadOTP:OTP_Row_41[1]") + 256*256*:Name("223:ReadOTP:OTP_Row_49[1]") + 256*256*256*:Name("224:ReadOTP:OTP_Row_4a[1]") + 256*256*256*256*Abs(:Name("123:LOG_SETPOINT_SPEA:SPEA_Setpoint[1]")));
	
	rowValue = {:Name("start_t"), :Name("part_id"), Row()};
	
	If (Is List(lastTests[partKey]) ==  1,
		If ( rowValue[1] &amp;gt; lastTests[partKey][1], //if start_t is later
			lastTests[partKey] = rowValue,
		
		//else if
		(rowValue[1] == lastTests[partKey][1]) &amp;amp; (rowValue[2] &amp;gt; lastTests[partKey][2]), //if start_t is the same but part_id is larger
			lastTests[partKey] = rowValue;
			
		
		),
	//else
		lastTests[partKey] = rowValue;
	
	);
	
	
);

listOfRowsToSelect = {};

listOfVals = lastTests &amp;lt;&amp;lt; Get Values;

For(i = 1, i &amp;lt;= nrows(listOfVals), i++,
	Insert Into(listOfRowsToSelect, listOfVals[i][3]);

);

dt &amp;lt;&amp;lt; Select Rows( listOfRowsToSelect );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;And this is the error I see in the log:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;subscripted key not in map["192344950106"]{1} in access or evaluation of 'partKey' , partKey/*###*/

In the following script, error marked by /*###*/
dt = Current Data Table();
lastTests = Associative Array();
For Each Row(
	partKey = Char(
		:Name( "214:ReadOTP:OTP_Row_40[1]" ) + 256 *
		:Name( "215:ReadOTP:OTP_Row_41[1]" ) + 256 * 256 *
		:Name( "223:ReadOTP:OTP_Row_49[1]" ) + 256 * 256 * 256 *
		:Name( "224:ReadOTP:OTP_Row_4a[1]" ) + 256 * 256 * 256 * 256 *
		Abs( :Name( "123:LOG_SETPOINT_SPEA:SPEA_Setpoint[1]" ) )
	);
	rowValue = {:start_t, :part_id, Row()};
	If( Is List( lastTests[partKey/*###*/] ) == 1,
		If(
			rowValue[1] &amp;gt; lastTests[partKey][1], lastTests[partKey] = rowValue,
			rowValue[1] == lastTests[partKey][1] &amp;amp; rowValue[2] &amp;gt; lastTests[partKey][
			2], lastTests[partKey] = rowValue
		),
		lastTests[partKey] = rowValue
	);
);
listOfRowsToSelect = {};
listOfVals = lastTests &amp;lt;&amp;lt; Get Values;
For( i = 1, i &amp;lt;= N Rows( listOfVals ), i++,
	Insert Into( listOfRowsToSelect, listOfVals[i][3] )
);
dt &amp;lt;&amp;lt; Select Rows( listOfRowsToSelect );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 18:19:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Is-it-possible-to-iterate-through-all-elements-in-an-associative/m-p/53139#M30079</guid>
      <dc:creator>tatarjj</dc:creator>
      <dc:date>2018-03-14T18:19:35Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to iterate through all elements in an associative array?</title>
      <link>https://community.jmp.com/t5/Discussions/Is-it-possible-to-iterate-through-all-elements-in-an-associative/m-p/53140#M30080</link>
      <description>&lt;P&gt;I also tried the Is Empty function (switching the 1 to a 0 in the comparison as well), and it gave me the same error.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 18:20:30 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Is-it-possible-to-iterate-through-all-elements-in-an-associative/m-p/53140#M30080</guid>
      <dc:creator>tatarjj</dc:creator>
      <dc:date>2018-03-14T18:20:30Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to iterate through all elements in an associative array?</title>
      <link>https://community.jmp.com/t5/Discussions/Is-it-possible-to-iterate-through-all-elements-in-an-associative/m-p/53142#M30082</link>
      <description>&lt;P&gt;The &lt;STRONG&gt;getkeys&lt;/STRONG&gt; method returns all of the keys for an associative array.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;aa = associative array();
aa["One"] = {1, 2, 3};
aa["Two"] = {"a", "b", "c"};
key_list = aa &amp;lt;&amp;lt; getkeys();

// Results shown in the log:
{"One", "Two"}&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Mar 2018 18:37:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Is-it-possible-to-iterate-through-all-elements-in-an-associative/m-p/53142#M30082</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2018-03-14T18:37:52Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to iterate through all elements in an associative array?</title>
      <link>https://community.jmp.com/t5/Discussions/Is-it-possible-to-iterate-through-all-elements-in-an-associative/m-p/53143#M30083</link>
      <description>&lt;P&gt;Yes, but this script and its derivatives I plan to make need to operate on a data table with well over three hundred thousand rows, each with hundreds of columns (if my computer can't handle that; if not, then I'll have to break it up some, but the table size for each database fragment will still be HUGE).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, it is&lt;STRONG&gt; critically important&lt;/STRONG&gt; to optimize this code so that it runs as efficiently as possible.&amp;nbsp; Running Get Keys on the associative array and then seaching the huge list of tens or hundreds of thousands of entries &lt;EM&gt;simply&lt;/EM&gt;&amp;nbsp;to see if the returned list contains a value seems HORRIBLY inefficient when all I need to do is see if lastTests[partKey] has a value assigned to it or not!&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 18:46:03 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Is-it-possible-to-iterate-through-all-elements-in-an-associative/m-p/53143#M30083</guid>
      <dc:creator>tatarjj</dc:creator>
      <dc:date>2018-03-14T18:46:03Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to iterate through all elements in an associative array?</title>
      <link>https://community.jmp.com/t5/Discussions/Is-it-possible-to-iterate-through-all-elements-in-an-associative/m-p/53145#M30085</link>
      <description>&lt;P&gt;Understood.&amp;nbsp; I did a test with an associative array with 20,000 keys.&amp;nbsp; I used a contains search to look for each of the 20,000 keys; took 12 seconds.&amp;nbsp; Looking for an individual key takes a fraction of a second.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// Look for one key
start = hp time();
zlist = aa &amp;lt;&amp;lt; getkeys();	// Contains 20,000 keys
a     = "xyz9999";
flag  = contains(zlist, a);
end   = hp time();
show((end - start)/1000000);
// .012 seconds

// Search for all keys using CONTAINS
start = hp time();
for (i = 1, i &amp;lt;= nitems(xlist), i++,   // xlist contains the keys in order of creation
	x = xlist[i];
	b = contains(zlist, x);        // zlist comes from getkeys and is not in order of creation
);
end = hp time();
show((end - start)/1000000);
// 12.2 seconds
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Mar 2018 19:09:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Is-it-possible-to-iterate-through-all-elements-in-an-associative/m-p/53145#M30085</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2018-03-14T19:09:06Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to iterate through all elements in an associative array?</title>
      <link>https://community.jmp.com/t5/Discussions/Is-it-possible-to-iterate-through-all-elements-in-an-associative/m-p/53146#M30086</link>
      <description>&lt;P&gt;So, do you know for certain that there is no way to test an associative array to see if a key exists without using the Get Keys function? Does an associative array always generate an error when you attempt to access a key that doesn't exist yet?&lt;BR /&gt;&lt;BR /&gt;12 ms is going to be very problematic, that is a tremendously long time just to determine if a value exists at a certain key. I'm pretty certain other scripting languages do this in microsecond time scales; I know that Lua does it incredibly fast (compared to 12ms, at least). If I'm dealing with a data table of 300k rows, then actually that could be about 300k keys. So the execution time could increase to (300k/20k)*12 ms = 180 ms. BUT, that would then have to run about 300k times, so the total execution time becomes 15 hours (180 ms * 3e5 = 15 hours). Actually, it would probably be about half of that, since the associative array would be growing as the loop runs. But 7.5 hours is still too long.&lt;BR /&gt;&lt;BR /&gt;However, perhaps it is not the Contains function which chews up the majority of the execution time (within the 12 ms) but the Get Keys function?&amp;nbsp; In my script, I wouldn't even have to run Get Keys &lt;EM&gt;at all&lt;/EM&gt; if&amp;nbsp;I just keep (in parallel) a separate List of keys that I had added into the associative array.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 19:43:17 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Is-it-possible-to-iterate-through-all-elements-in-an-associative/m-p/53146#M30086</guid>
      <dc:creator>tatarjj</dc:creator>
      <dc:date>2018-03-14T19:43:17Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to iterate through all elements in an associative array?</title>
      <link>https://community.jmp.com/t5/Discussions/Is-it-possible-to-iterate-through-all-elements-in-an-associative/m-p/53147#M30087</link>
      <description>&lt;P&gt;You could wrap a simple test for the key value in a &lt;STRONG&gt;try()&lt;/STRONG&gt; section.&amp;nbsp; Not sure of the performance vs &lt;STRONG&gt;contains&lt;/STRONG&gt;.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;found = 0;
try(
	b = aa["junk"];   // This key is not in the associative array
	found = 1;
);
show(found);   // Returns 1 if found, 0 if not found.  1 is the same as TRUE, 0 is the same as FALSE&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Mar 2018 19:52:28 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Is-it-possible-to-iterate-through-all-elements-in-an-associative/m-p/53147#M30087</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2018-03-14T19:52:28Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to iterate through all elements in an associative array?</title>
      <link>https://community.jmp.com/t5/Discussions/Is-it-possible-to-iterate-through-all-elements-in-an-associative/m-p/53148#M30088</link>
      <description>&lt;P&gt;Cool. I was hoping JMP had something like Try.&amp;nbsp; I will try Try :)&lt;/img&gt; and compare its execution time vs Contains when I get the time later.&amp;nbsp; Thank you very much for the help.&amp;nbsp; I will post updates when I have them.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 19:57:33 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Is-it-possible-to-iterate-through-all-elements-in-an-associative/m-p/53148#M30088</guid>
      <dc:creator>tatarjj</dc:creator>
      <dc:date>2018-03-14T19:57:33Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to iterate through all elements in an associative array?</title>
      <link>https://community.jmp.com/t5/Discussions/Is-it-possible-to-iterate-through-all-elements-in-an-associative/m-p/53167#M30098</link>
      <description>&lt;P&gt;I think I got it working finally.&amp;nbsp; I wish I could assign values to a list in the same line that I constructed it, and get rid of all the Insert Into commands.&amp;nbsp;&amp;nbsp;Do I really have to do this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;	rowValue = {};
	Insert Into(rowValue, :Name("start_t"));
	Insert Into(rowValue, :Name("part_id"));
	Insert Into(rowValue, Row());
	&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;When I really just want to do this?&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;rowValue = {:Name("start_t"), :Name("part_id"), Row()};&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;With the latter, however, the value of the list at index 3 is literally just the text "Row()"!&amp;nbsp; Shouldn't it run the Row() function and return the value?!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a known issue in Windows 10 with the Script window being incredibly sluggish?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyway, this is the script in the form&amp;nbsp;where it finally APPEARS to be working (need to fully verify):&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Current Data Table();
dt &amp;lt;&amp;lt; Clear Select;

lastTests = Associative Array();



//For(i = 1, i &amp;lt;= N Rows(dt), i++,

For Each Row (
	//Row() = i;
	
	partKey = Char(:Name("214:ReadOTP:OTP_Row_40[1]") + 256*:Name("215:ReadOTP:OTP_Row_41[1]") + 256*256*:Name("223:ReadOTP:OTP_Row_49[1]") + 256*256*256*:Name("224:ReadOTP:OTP_Row_4a[1]") + 256*256*256*256*Abs(:Name("123:LOG_SETPOINT_SPEA:SPEA_Setpoint[1]")));
	
	rowValue = {};
	Insert Into(rowValue, :Name("start_t"));
	Insert Into(rowValue, :Name("part_id"));
	Insert Into(rowValue, Row());
	
	//rowValue = {:Name("start_t"), :Name("part_id"), i};
	
	hasValue = 0;
	try(
		junk = lastTests[partKey];
		hasValue = 1;
	);

	If ( hasValue ==  1,
		If ( rowValue[1] &amp;gt; lastTests[partKey][1], //if start_t is later
			lastTests[partKey] = rowValue,
		
		//else if
		(rowValue[1] == lastTests[partKey][1]) &amp;amp; (rowValue[2] &amp;gt; lastTests[partKey][2]), //if start_t is the same but part_id is larger
			lastTests[partKey] = rowValue;
			
		
		),
	//else
		lastTests[partKey] = rowValue;
	
	);
	
	
);

listOfRowsToSelect = {};


listOfVals = lastTests &amp;lt;&amp;lt; Get Values;
//Show(N Items(listOfVals));

For(i = 1, i &amp;lt;= N Items(listOfVals), i++,
	Insert Into(listOfRowsToSelect, listOfVals[i][3]);

//Print(listOfVals[i][3]);
);

dt &amp;lt;&amp;lt; Select Rows( listOfRowsToSelect );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Mar 2018 00:42:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Is-it-possible-to-iterate-through-all-elements-in-an-associative/m-p/53167#M30098</guid>
      <dc:creator>tatarjj</dc:creator>
      <dc:date>2018-03-15T00:42:36Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to iterate through all elements in an associative array?</title>
      <link>https://community.jmp.com/t5/Discussions/Is-it-possible-to-iterate-through-all-elements-in-an-associative/m-p/53189#M30110</link>
      <description>&lt;P&gt;Still tricky.&amp;nbsp; Use &lt;STRONG&gt;evallist()&lt;/STRONG&gt; to do it in one step.&amp;nbsp; Also, instead of saying &lt;STRONG&gt;if (hasvalue == 1,&lt;/STRONG&gt;&amp;nbsp;just say &lt;STRONG&gt;if (hasvalue,&lt;/STRONG&gt;.&amp;nbsp; A positive integer is True in JSL, 0 is false.&amp;nbsp; Here are some ways to do what you want.&amp;nbsp; One way loops over all the rows explicitly, the other uses &lt;STRONG&gt;for each row&lt;/STRONG&gt;.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = open("$sample_data\Big Class.jmp");
for (i = 1, i &amp;lt;= nrows(dt), i++,
	rowvalue = evallist({column(dt, "age")[i], column(dt, "height")[i], i});
	print(rowvalue);
);

current data table(dt);
for each row(
	rowvalue = evallist({as column(dt, "age"), as column(dt, "height"), row()});
// This works too
//	rowvalue = evallist({:name("age"), :name("height"), row()});
	print(rowvalue);
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Mar 2018 13:07:42 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Is-it-possible-to-iterate-through-all-elements-in-an-associative/m-p/53189#M30110</guid>
      <dc:creator>pmroz</dc:creator>
      <dc:date>2018-03-15T13:07:42Z</dc:date>
    </item>
  </channel>
</rss>

