<?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: Saving incremented variable names in For loop to a list in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Saving-incremented-variable-names-in-For-loop-to-a-list/m-p/268245#M52230</link>
    <description>&lt;P&gt;That period was hard to see !!!!&lt;/P&gt;</description>
    <pubDate>Fri, 22 May 2020 00:35:08 GMT</pubDate>
    <dc:creator>jimloughlin</dc:creator>
    <dc:date>2020-05-22T00:35:08Z</dc:date>
    <item>
      <title>Saving incremented variable names in For loop to a list</title>
      <link>https://community.jmp.com/t5/Discussions/Saving-incremented-variable-names-in-For-loop-to-a-list/m-p/267618#M52105</link>
      <description>&lt;P&gt;I am trying to&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) Open a series of files that are listed in the list Unique_Files&lt;/P&gt;&lt;P&gt;2) If the file doesn't exist, then a dialog box opens up with a message indicating the file exists&lt;/P&gt;&lt;P&gt;3) If the file does exist, then open the file in JMP&lt;/P&gt;&lt;P&gt;4) If the file does exist, then add the data table reference name to the list UniqueTables&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Every other part of my script seems to be working except being able to create a list of the data table reference name.&amp;nbsp; The way my script is written below results in the list&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;UniqueTables = { DataTable("filename1"), Data Table("filename2"),....}&lt;BR /&gt;&lt;BR /&gt;Instead I want the script to result in the list as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;UniqueTables = My_Table_1, My_Table_2, My_Table_3,...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;N Items (Unique_Files);

UniqueTables = { };

For ( i = 1, i &amp;lt;= N, i ++,
     If(
          File Exists( "C:\PretendFilePath\" ||Unique_Files[i]|| ".csv"),
          Eval(
               Substitute(
                    Expr( 
                         MyTab = Open( "C:\PretendFilePath\" ||Unique_Files[i]|| ".csv");
                         Insert Into( UniqueTables, MyTab) 
                    ),
                    Expr( MyTab),
                    Parse( My_Table_" ||Char(i))
               )
          ),
          New Window ("File Not Found",
               &amp;lt;&amp;lt; Modal,
               V List Box(
                    Text Box( Unique_Files[i]|| " does not exist in folder."),
                    Button Box( "OK")
               )
          )
     )
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 May 2020 08:26:39 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Saving-incremented-variable-names-in-For-loop-to-a-list/m-p/267618#M52105</guid>
      <dc:creator>user8421</dc:creator>
      <dc:date>2020-05-19T08:26:39Z</dc:date>
    </item>
    <item>
      <title>Re: Saving incremented variable names in For loop to a list</title>
      <link>https://community.jmp.com/t5/Discussions/Saving-incremented-variable-names-in-For-loop-to-a-list/m-p/267633#M52111</link>
      <description>&lt;P&gt;All you need to do is to retrieve the table name from the data table reference, so change your reference to "Mytab" to:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt; Insert Into( UniqueTables, MyTab &amp;lt;&amp;lt; get name)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;All of the messages for the various elements in JSL are documented in the Scripting Guide&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; Help==&amp;gt;Scripting Guide&lt;/P&gt;</description>
      <pubDate>Tue, 19 May 2020 09:20:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Saving-incremented-variable-names-in-For-loop-to-a-list/m-p/267633#M52111</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-05-19T09:20:06Z</dc:date>
    </item>
    <item>
      <title>Re: Saving incremented variable names in For loop to a list</title>
      <link>https://community.jmp.com/t5/Discussions/Saving-incremented-variable-names-in-For-loop-to-a-list/m-p/267677#M52122</link>
      <description>&lt;P&gt;Can I ask why you want to do this?&amp;nbsp; Doing this makes the script very hard to support because you can't find variable names. I fix scripts once the owners can't understand their own code anymore and this is always something I'm running into.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What does giving multiple variables give you that a list doesn't?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Because it seems unnecessary to have&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;UniqueTables[1] = My_Table_1 = DataTable("filename1");&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 May 2020 13:46:03 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Saving-incremented-variable-names-in-For-loop-to-a-list/m-p/267677#M52122</guid>
      <dc:creator>vince_faller</dc:creator>
      <dc:date>2020-05-19T13:46:03Z</dc:date>
    </item>
    <item>
      <title>Re: Saving incremented variable names in For loop to a list</title>
      <link>https://community.jmp.com/t5/Discussions/Saving-incremented-variable-names-in-For-loop-to-a-list/m-p/268189#M52216</link>
      <description>&lt;P&gt;Hi Jim,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Unfortunately I'm still not getting the desired result because I wasn't clear in how I explained my situation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I should have specified that the Unique_Files list is the file name of the CSVs stored in the folder location.&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;Unique_Files = {"FileName1", "FileName2", "FileName3", etc...}
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;Using the &amp;lt;&amp;lt; Get Name function results in the UniqueTables list as&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;UniqueTables = {"FileName1", "FileName2", "FileName3", etc...}&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;When I'm looking for&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;UniqueTables = {My_Table_1, My_Table_2, My_Table_3, etc...}&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;Once I get the UniqueTables list together in that format my plan was to concatenate some of those tables together and close the source tables that were concatenated.&amp;nbsp; I only know how to do this with the table reference name of My_Table_1.&amp;nbsp; Is there a way to concatenate tables from their file name of "FileName1"?&amp;nbsp; If there is, then I can bypass this issue altogether.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks in advance!&amp;nbsp; You have been very helpful.&lt;/P&gt;</description>
      <pubDate>Thu, 21 May 2020 19:41:42 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Saving-incremented-variable-names-in-For-loop-to-a-list/m-p/268189#M52216</guid>
      <dc:creator>user8421</dc:creator>
      <dc:date>2020-05-21T19:41:42Z</dc:date>
    </item>
    <item>
      <title>Re: Saving incremented variable names in For loop to a list</title>
      <link>https://community.jmp.com/t5/Discussions/Saving-incremented-variable-names-in-For-loop-to-a-list/m-p/268199#M52218</link>
      <description>&lt;P&gt;Check out what an &lt;A href="http://xyproblem.info/" target="_self"&gt;XY problem&lt;/A&gt; is, it will definitely help us help you.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But other than that.&amp;nbsp; If all you're trying to do is concat all the JMP files in a folder together.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names default to here( 1 );
// this is just creating an example set don't worry about it.  
dt = open("$SAMPLE_DATA\Big Class.jmp");
dir = convert file path("$DESKTOP\Example\");
Create Directory(dir);

for(i=1, i&amp;lt;=6, i++, 
	path = convert file path(char(i)||".jmp", base(dir));
	dt &amp;lt;&amp;lt; Save As(path);
);


// this is actually what you'll want to run
dir = convert file path("$DESKTOP\Example\");
// find the files in that directory
files = files in directory(dir);
// create a base table
dt_final = New Table("Concatted");

for(i=1, i&amp;lt;=nitems(files), i++, 
	
	dt = open(convert file path(files[i], base(dir)));
	dt_final &amp;lt;&amp;lt; Concatenate(dt, append to first table(1));
	close(dt, no save);
)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 May 2020 19:39:16 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Saving-incremented-variable-names-in-For-loop-to-a-list/m-p/268199#M52218</guid>
      <dc:creator>vince_faller</dc:creator>
      <dc:date>2020-05-21T19:39:16Z</dc:date>
    </item>
    <item>
      <title>Re: Saving incremented variable names in For loop to a list</title>
      <link>https://community.jmp.com/t5/Discussions/Saving-incremented-variable-names-in-For-loop-to-a-list/m-p/268203#M52219</link>
      <description>&lt;P&gt;You appear to have some lack of knowledge about what the various structures are actually giving you.&amp;nbsp; I strongly suggest that you take the time to read the Scripting Guide.&amp;nbsp; But, I also think the below might clear up some issues with your current code.&amp;nbsp; Take a look at my annotated code below, and see if it adds some light to the issues you are having.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;names default to here(1);

dt1=open("$SAMPLE_DATA/big class.jmp");
dt2=open("$SAMPLE_DATA/big class families.jmp");

// Here is what the value of dt1 is
show(dt1);
// From the log
// dt1 = DataTable("big class");
// Therefore the value of dt2 is,
show(dt2);
//  dt2 = DataTable("big class families");

// The structure of the Concatenate Platform syntax is:
// data table("data table name") &amp;lt;&amp;lt; Concatenate( data table("data table2 name"), data table("data table2 name") );

// That would mean that the following will concatenate our two files
data table( "big class" ) &amp;lt;&amp;lt; Concatenate( data table( "big class families" ) );

// It also means, that since we have variables dt1, which was shown to equal Data Table( "big class" ), and 
// dt2 which has the value of Data Table( "big class families" )
// the above concatenate statement can be written
dt1 &amp;lt;&amp;lt; Concatenate( dt2 );

// Here is another way to do this

UniqueTables = {};
MyTab = open("$SAMPLE_DATA/big class.jmp");

insert into( UniqueTables, MyTab );

MyTab = open("$SAMPLE_DATA/big class families.jmp");

insert into( UniqueTables, MyTab );

Show( UniqueTables );
// returns
// UniqueTables = {DataTable("big class"), DataTable("big class families")};

// So now the Concatenate statement can be written
UniqueTables[1] &amp;lt;&amp;lt; Concatenate( UniqueTables[2] );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 May 2020 00:10:33 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Saving-incremented-variable-names-in-For-loop-to-a-list/m-p/268203#M52219</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-05-22T00:10:33Z</dc:date>
    </item>
    <item>
      <title>Re: Saving incremented variable names in For loop to a list</title>
      <link>https://community.jmp.com/t5/Discussions/Saving-incremented-variable-names-in-For-loop-to-a-list/m-p/268240#M52228</link>
      <description>&lt;P&gt;On the last line I get the following error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unexpected "UniqueTables". Perhaps there is a missing ";" or ",".&lt;BR /&gt;Line 42 Column 1: ►UniqueTables[1] &amp;lt;&amp;lt; Concatenate( UniqueTables[2] );&lt;BR /&gt;The remaining text that was ignored was&lt;BR /&gt;UniqueTables[1]&amp;lt;&amp;lt;Concatenate(UniqueTables[2]);&lt;/P&gt;</description>
      <pubDate>Thu, 21 May 2020 22:27:04 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Saving-incremented-variable-names-in-For-loop-to-a-list/m-p/268240#M52228</guid>
      <dc:creator>jimloughlin</dc:creator>
      <dc:date>2020-05-21T22:27:04Z</dc:date>
    </item>
    <item>
      <title>Re: Saving incremented variable names in For loop to a list</title>
      <link>https://community.jmp.com/t5/Discussions/Saving-incremented-variable-names-in-For-loop-to-a-list/m-p/268244#M52229</link>
      <description>&lt;P&gt;Some how a period "." ended up after&lt;/P&gt;
&lt;PRE&gt;&lt;SPAN class="token function" style="box-sizing: border-box; color: blue; font-family: Consolas,Monaco,&amp;amp;quot; andale mono&amp;amp;quot;,&amp;amp;quot;ubuntu mono&amp;amp;quot;,monospace; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 300; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;Show&lt;/SPAN&gt;&lt;SPAN class="token punctuation" style="box-sizing: border-box; color: #000000; font-family: Consolas,Monaco,&amp;amp;quot; andale mono&amp;amp;quot;,&amp;amp;quot;ubuntu mono&amp;amp;quot;,monospace; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 300; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="display: inline !important; float: none; background-color: #ffffff; color: black; direction: ltr; font-family: Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace; font-size: inherit; font-style: normal; font-variant: normal; font-weight: 300; letter-spacing: normal; line-height: 1.5; -ms-hyphens: none; orphans: 2; overflow-wrap: normal; text-align: left; text-decoration: none; text-indent: 0px; text-shadow: 0px 1px white; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-break: normal; word-spacing: normal;"&gt; UniqueTables &lt;/SPAN&gt;&lt;SPAN class="token punctuation" style="box-sizing: border-box; color: #000000; font-family: Consolas,Monaco,&amp;amp;quot; andale mono&amp;amp;quot;,&amp;amp;quot;ubuntu mono&amp;amp;quot;,monospace; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 300; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;)&lt;/SPAN&gt;&lt;SPAN class="token punctuation" style="box-sizing: border-box; color: #000000; font-family: Consolas,Monaco,&amp;amp;quot; andale mono&amp;amp;quot;,&amp;amp;quot;ubuntu mono&amp;amp;quot;,monospace; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 300; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;;&lt;/SPAN&gt;&lt;SPAN class="token punctuation" style="box-sizing: border-box; color: #000000; font-family: Consolas,Monaco,&amp;amp;quot; andale mono&amp;amp;quot;,&amp;amp;quot;ubuntu mono&amp;amp;quot;,monospace; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 300; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: pre; word-spacing: 0px;"&gt;.&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;so remove it and it will work fine.....I will correct the previous example for future references.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 May 2020 00:10:00 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Saving-incremented-variable-names-in-For-loop-to-a-list/m-p/268244#M52229</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-05-22T00:10:00Z</dc:date>
    </item>
    <item>
      <title>Re: Saving incremented variable names in For loop to a list</title>
      <link>https://community.jmp.com/t5/Discussions/Saving-incremented-variable-names-in-For-loop-to-a-list/m-p/268245#M52230</link>
      <description>&lt;P&gt;That period was hard to see !!!!&lt;/P&gt;</description>
      <pubDate>Fri, 22 May 2020 00:35:08 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Saving-incremented-variable-names-in-For-loop-to-a-list/m-p/268245#M52230</guid>
      <dc:creator>jimloughlin</dc:creator>
      <dc:date>2020-05-22T00:35:08Z</dc:date>
    </item>
    <item>
      <title>Re: Saving incremented variable names in For loop to a list</title>
      <link>https://community.jmp.com/t5/Discussions/Saving-incremented-variable-names-in-For-loop-to-a-list/m-p/268246#M52231</link>
      <description>&lt;P&gt;yup&lt;/P&gt;</description>
      <pubDate>Fri, 22 May 2020 00:39:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Saving-incremented-variable-names-in-For-loop-to-a-list/m-p/268246#M52231</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-05-22T00:39:34Z</dc:date>
    </item>
  </channel>
</rss>

