<?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 How to convert the name of list into a string? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-convert-the-name-of-list-into-a-string/m-p/41054#M23945</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have this script which checks if the list has duplicate elements, and if it does, it sends error message.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;ColAgain=Function({main}, {duplicate},
					duplicate={};
					duplicate_r={};
					unique={};
					For (i=1,i&amp;lt;=Nitems(main),i++,
						If (Nrows(Loc(unique,main[i])) == 0,
							InsertInto (unique,main[i]),
							InsertInto (duplicate_r,main[i])
							);
						);
					For (i=1,i&amp;lt;=Nitems(duplicate_r),i++,
						If (Nrows(Loc(duplicate,duplicate_r[i])) == 0,
							InsertInto (duplicate,duplicate_r[i])
							);

						);
					if (Nitems(duplicate)&amp;gt;0,
						Write("ERROR. "||Char(main)||" has duplicates.");
						Caption("ERROR. "||Char(main)||" has duplicates. Check log.");
						For (i=1, i&amp;lt;=Nitems(duplicate), i++,
							 Show(duplicate[i]);
							);
					Throw();
						);
					duplicate;
				 );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Notice that I have this line:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Caption("ERROR. "||Char(main)||" has duplicates. Check log.");&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;What I want to appear is this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;"ERROR. GroupVar has duplicates. Check log."&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However, this appears instead:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;"ERROR. {"Element1", "Element2, "ElementN"} has duplicates. Check log."&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Any ideas? Thanks.&lt;/P&gt;</description>
    <pubDate>Thu, 22 Jun 2017 05:46:30 GMT</pubDate>
    <dc:creator>shaira</dc:creator>
    <dc:date>2017-06-22T05:46:30Z</dc:date>
    <item>
      <title>How to convert the name of list into a string?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-convert-the-name-of-list-into-a-string/m-p/41054#M23945</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I have this script which checks if the list has duplicate elements, and if it does, it sends error message.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;ColAgain=Function({main}, {duplicate},
					duplicate={};
					duplicate_r={};
					unique={};
					For (i=1,i&amp;lt;=Nitems(main),i++,
						If (Nrows(Loc(unique,main[i])) == 0,
							InsertInto (unique,main[i]),
							InsertInto (duplicate_r,main[i])
							);
						);
					For (i=1,i&amp;lt;=Nitems(duplicate_r),i++,
						If (Nrows(Loc(duplicate,duplicate_r[i])) == 0,
							InsertInto (duplicate,duplicate_r[i])
							);

						);
					if (Nitems(duplicate)&amp;gt;0,
						Write("ERROR. "||Char(main)||" has duplicates.");
						Caption("ERROR. "||Char(main)||" has duplicates. Check log.");
						For (i=1, i&amp;lt;=Nitems(duplicate), i++,
							 Show(duplicate[i]);
							);
					Throw();
						);
					duplicate;
				 );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Notice that I have this line:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Caption("ERROR. "||Char(main)||" has duplicates. Check log.");&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;What I want to appear is this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;"ERROR. GroupVar has duplicates. Check log."&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However, this appears instead:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;"ERROR. {"Element1", "Element2, "ElementN"} has duplicates. Check log."&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Any ideas? Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2017 05:46:30 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-convert-the-name-of-list-into-a-string/m-p/41054#M23945</guid>
      <dc:creator>shaira</dc:creator>
      <dc:date>2017-06-22T05:46:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert the name of list into a string?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-convert-the-name-of-list-into-a-string/m-p/41058#M23948</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/8603"&gt;@shaira&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;I assume you want the VARIABLE name that is supplied as the function argument, to be displayed in the caption box? If so, this may work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;ColAgain = Function( {main},
	{duplicate},
	duplicate = {};
	duplicate_r = {};
	unique = {};
	For( i = 1, i &amp;lt;= N Items( main ), i++,
		If( N Rows( Loc( unique, main[i] ) ) == 0,
			Insert Into( unique, main[i] ),
			Insert Into( duplicate_r, main[i] )
		)
	);
	For( i = 1, i &amp;lt;= N Items( duplicate_r ), i++,
		If( N Rows( Loc( duplicate, duplicate_r[i] ) ) == 0,
			Insert Into( duplicate, duplicate_r[i] )
		);

	);
	If( N Items( duplicate ) &amp;gt; 0,
		Write( "ERROR. " || Char( main ) || " has duplicates." );
		Caption( "ERROR. " || Char( nameExpr(main) ) || " has duplicates. Check log." );
		For( i = 1, i &amp;lt;= N Items( duplicate ), i++,
			Show( duplicate[i] )
		);
		Throw();
	);
	duplicate;
);

groupVar = {1,2,3,3,5};
ColAgain( expr(groupVar) );&lt;/CODE&gt;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note the use of Name Expr() in the Caption statement. Also, when calling the function, you have to wrap the argument with the keyword Expr()&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2017 07:39:49 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-convert-the-name-of-list-into-a-string/m-p/41058#M23948</guid>
      <dc:creator>Phil_Brown</dc:creator>
      <dc:date>2017-06-22T07:39:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert the name of list into a string?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-convert-the-name-of-list-into-a-string/m-p/41105#M23968</link>
      <description>Thanks! It works perfectly well.</description>
      <pubDate>Fri, 23 Jun 2017 00:07:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-convert-the-name-of-list-into-a-string/m-p/41105#M23968</guid>
      <dc:creator>shaira</dc:creator>
      <dc:date>2017-06-23T00:07:53Z</dc:date>
    </item>
  </channel>
</rss>

