<?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: Storing data tables as metadata (table variables) JSL in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Storing-data-tables-as-metadata-table-variables-JSL/m-p/625145#M82396</link>
    <description>&lt;P&gt;Here are three examples that embed the data for table B in table A . I prefer the dtb3 example for reasonable sized tables. The dtb4 example is what I think you described; it is maybe better for a huge B table, but it is very opaque to anyone else. dtb5 combines the two ideas.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// Make sample tables. When done, aa will have two table scripts and a table variable.
// the scripts and variables show three ways to embed bb in aa.
dta = New Table( "aa", New Column( "a", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1] ) ) );
dtb = New Table( "bb", New Column( "b", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [2] ) ) );

// dtb3: I think you should do this with a table script because it can be
// opened from the GUI or from JSL. The downside is if the table is
// very large it will be slow to save and slow to open because it is
// making a script to recreate the table.
Eval( Eval Expr( dta &amp;lt;&amp;lt; NewScript( "bbb", Expr( dtb &amp;lt;&amp;lt; getScript ) ) ) );
// jsl to open:
dtb3 = Eval( dta &amp;lt;&amp;lt; getScript( "bbb" ) );
dtb3 &amp;lt;&amp;lt; SetName( "dtb3" ); // optional, was "bb 2"


// dtb4: it gets ugly with a table variable, there are several possibilities. This
// will save the table and grab the binary from the disk file and make a character
// string from that. You might choose to do this for a really large file, but I'm
// not sure what issues you'll run into. 
dtb &amp;lt;&amp;lt; Save( "$temp/bb.jmp" );
blob = Load Text File( "$temp/bb.jmp", blob );
blob = Gzip Compress( blob );// optional
text = Char( blob );
dta &amp;lt;&amp;lt; SetTableVariable( "bbbb", text );
// reopen
text = dta:bbbb;
blob = Parse( text );
blob = Gzip Uncompress( blob );//optional
dtb4 = Open( blob, "jmp" );
dtb4 &amp;lt;&amp;lt; SetName( "dtb4" ); // optional, was "untitled"


// dtb5: you could combine the two ideas, saving the binary data as a table script so
// it can be used from the GUI
dtb &amp;lt;&amp;lt; Save( "$temp/bb.jmp" );
blob = Load Text File( "$temp/bb.jmp", blob );
blob = Gzip Compress( blob );// optional
text = Char( blob );
Eval(
	Eval Expr(
		dta &amp;lt;&amp;lt; NewScript(
			"bbbbb",
			Local( {text, blob, dt},
				text = Expr( text );
				blob = Parse( text );
				blob = Gzip Uncompress( blob );//optional
				dt = Open( blob, "jmp" );
				dt;
			)
		)
	)
);
// reopen 
dtb5 = Eval( dta &amp;lt;&amp;lt; getScript( "bbbbb" ) );
dtb5 &amp;lt;&amp;lt; SetName( "dtb5" ); // optional, was "untitled"
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 22 Apr 2023 13:04:56 GMT</pubDate>
    <dc:creator>Craige_Hales</dc:creator>
    <dc:date>2023-04-22T13:04:56Z</dc:date>
    <item>
      <title>Storing data tables as metadata (table variables) JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Storing-data-tables-as-metadata-table-variables-JSL/m-p/623858#M82274</link>
      <description>&lt;P&gt;Table variables are used to store metadata within a data table (&lt;A href="https://www.jmp.com/support/help/en/17.1/index.shtml#page/jmp/add-metadata-to-a-data-table.shtml#ww675914" target="_self"&gt;JSL doc&lt;/A&gt;, &lt;A href="https://www.jmp.com/support/help/en/17.1/index.shtml#page/jmp/use-data-table-variables.shtml" target="_self"&gt;general doc&lt;/A&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, they seem to be limited to variables as strings only (see code below).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What would be the best option to store a data table as a table variable?&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 );

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

dt_metadata = Open( "$SAMPLE_DATA/Solubility.jmp" );

dt &amp;lt;&amp;lt; Set Table Variable( "dt_user", dt_metadata );

close(dt_metadata);

dt_recovered = dt &amp;lt;&amp;lt; Get Table Variable("dt_user");

show(dt_recovered);
show(Is String(dt_recovered));

//dt_recovered = "Solubility";
//Is String(dt_recovered) = 1;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Jun 2023 16:08:26 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Storing-data-tables-as-metadata-table-variables-JSL/m-p/623858#M82274</guid>
      <dc:creator>FN</dc:creator>
      <dc:date>2023-06-09T16:08:26Z</dc:date>
    </item>
    <item>
      <title>Re: Storing data tables as metadata (table variables) JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Storing-data-tables-as-metadata-table-variables-JSL/m-p/623927#M82281</link>
      <description>&lt;P&gt;&lt;A href="https://community.jmp.com/t5/Discussions/difference-between-set-and-new-table-variable-strange-results-in/m-p/429212/highlight/true#M67868" target="_self"&gt;https://community.jmp.com/t5/Discussions/difference-between-set-and-new-table-variable-strange-results-in/m-p/429212/highlight/true#M67868&lt;/A&gt; from &lt;LI-MESSAGE title="difference between set and new table variable - strange results in writing string?" uid="428036" url="https://community.jmp.com/t5/Discussions/difference-between-set-and-new-table-variable-strange-results-in/m-p/428036#U428036" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-forum-thread lia-fa-icon lia-fa-forum lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp; describes four different functions, set/get/new table variable and dt:tablevar and recommends using set table variable and dt:tablevar.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2023 15:26:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Storing-data-tables-as-metadata-table-variables-JSL/m-p/623927#M82281</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2023-04-19T15:26:13Z</dc:date>
    </item>
    <item>
      <title>Re: Storing data tables as metadata (table variables) JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Storing-data-tables-as-metadata-table-variables-JSL/m-p/624780#M82352</link>
      <description>&lt;P&gt;The variable to store is a data table. The dt:tablevar doesn't seem to work in this case.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2023 11:11:59 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Storing-data-tables-as-metadata-table-variables-JSL/m-p/624780#M82352</guid>
      <dc:creator>FN</dc:creator>
      <dc:date>2023-04-21T11:11:59Z</dc:date>
    </item>
    <item>
      <title>Re: Storing data tables as metadata (table variables) JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Storing-data-tables-as-metadata-table-variables-JSL/m-p/624906#M82361</link>
      <description>&lt;P&gt;Table variables are character strings.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want dt_recovered to be the same after you'll need to convert dt_metadata into the character string representation of the expression when you store it in the table variable. You'll then need to Parse it when you get it back out of the variable.&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 );

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

dt_metadata = Open( "$SAMPLE_DATA/Solubility.jmp" );

dt &amp;lt;&amp;lt; Set Table Variable( "dt_user", char(dt_metadata));

close(dt_metadata);

dt_recovered = parse(dt &amp;lt;&amp;lt; Get Table Variable("dt_user"));

show(dt_recovered);
show(Is String(dt_recovered));

//dt_recovered = Data Table("Solubility.jmp");

//Is String(dt_recovered) = 0;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2023 15:12:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Storing-data-tables-as-metadata-table-variables-JSL/m-p/624906#M82361</guid>
      <dc:creator>Jeff_Perkinson</dc:creator>
      <dc:date>2023-04-21T15:12:45Z</dc:date>
    </item>
    <item>
      <title>Re: Storing data tables as metadata (table variables) JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Storing-data-tables-as-metadata-table-variables-JSL/m-p/625145#M82396</link>
      <description>&lt;P&gt;Here are three examples that embed the data for table B in table A . I prefer the dtb3 example for reasonable sized tables. The dtb4 example is what I think you described; it is maybe better for a huge B table, but it is very opaque to anyone else. dtb5 combines the two ideas.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// Make sample tables. When done, aa will have two table scripts and a table variable.
// the scripts and variables show three ways to embed bb in aa.
dta = New Table( "aa", New Column( "a", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1] ) ) );
dtb = New Table( "bb", New Column( "b", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [2] ) ) );

// dtb3: I think you should do this with a table script because it can be
// opened from the GUI or from JSL. The downside is if the table is
// very large it will be slow to save and slow to open because it is
// making a script to recreate the table.
Eval( Eval Expr( dta &amp;lt;&amp;lt; NewScript( "bbb", Expr( dtb &amp;lt;&amp;lt; getScript ) ) ) );
// jsl to open:
dtb3 = Eval( dta &amp;lt;&amp;lt; getScript( "bbb" ) );
dtb3 &amp;lt;&amp;lt; SetName( "dtb3" ); // optional, was "bb 2"


// dtb4: it gets ugly with a table variable, there are several possibilities. This
// will save the table and grab the binary from the disk file and make a character
// string from that. You might choose to do this for a really large file, but I'm
// not sure what issues you'll run into. 
dtb &amp;lt;&amp;lt; Save( "$temp/bb.jmp" );
blob = Load Text File( "$temp/bb.jmp", blob );
blob = Gzip Compress( blob );// optional
text = Char( blob );
dta &amp;lt;&amp;lt; SetTableVariable( "bbbb", text );
// reopen
text = dta:bbbb;
blob = Parse( text );
blob = Gzip Uncompress( blob );//optional
dtb4 = Open( blob, "jmp" );
dtb4 &amp;lt;&amp;lt; SetName( "dtb4" ); // optional, was "untitled"


// dtb5: you could combine the two ideas, saving the binary data as a table script so
// it can be used from the GUI
dtb &amp;lt;&amp;lt; Save( "$temp/bb.jmp" );
blob = Load Text File( "$temp/bb.jmp", blob );
blob = Gzip Compress( blob );// optional
text = Char( blob );
Eval(
	Eval Expr(
		dta &amp;lt;&amp;lt; NewScript(
			"bbbbb",
			Local( {text, blob, dt},
				text = Expr( text );
				blob = Parse( text );
				blob = Gzip Uncompress( blob );//optional
				dt = Open( blob, "jmp" );
				dt;
			)
		)
	)
);
// reopen 
dtb5 = Eval( dta &amp;lt;&amp;lt; getScript( "bbbbb" ) );
dtb5 &amp;lt;&amp;lt; SetName( "dtb5" ); // optional, was "untitled"
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 22 Apr 2023 13:04:56 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Storing-data-tables-as-metadata-table-variables-JSL/m-p/625145#M82396</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2023-04-22T13:04:56Z</dc:date>
    </item>
    <item>
      <title>Re: Storing data tables as metadata (table variables) JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Storing-data-tables-as-metadata-table-variables-JSL/m-p/625148#M82397</link>
      <description>&lt;P&gt;Or, if you mean to leave a link rather than embedding the data, perhaps use the file name for the linked table:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dta = New Table( "aa", New Column( "a", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [1] ) ) );
dtb = New Table( "bb", New Column( "b", Numeric, "Continuous", Format( "Best", 12 ), Set Values( [2] ) ) );
dta &amp;lt;&amp;lt; Save( "$temp/aa.jmp" );
dtb &amp;lt;&amp;lt; Save( "$temp/bb.jmp" );

// leave table B's filepath in table A

dta &amp;lt;&amp;lt; SetTableVariable("path to B", dtb&amp;lt;&amp;lt;getpath);

close(dtb);

dtb2 = open(dta:path to B); // apparently case matters with table variable names!&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 22 Apr 2023 13:50:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Storing-data-tables-as-metadata-table-variables-JSL/m-p/625148#M82397</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2023-04-22T13:50:38Z</dc:date>
    </item>
    <item>
      <title>Re: Storing data tables as metadata (table variables) JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Storing-data-tables-as-metadata-table-variables-JSL/m-p/769518#M95027</link>
      <description>&lt;P&gt;For columns a user can specify column properties - and there is even a possibility to define user-defined properties.&lt;BR /&gt;How about a similar framework for tables?&lt;BR /&gt;&lt;BR /&gt;Here is a wish :&lt;BR /&gt;&lt;LI-MESSAGE title="General information about table" uid="706321" url="https://community.jmp.com/t5/JMP-Wish-List/General-information-about-table/m-p/706321#U706321" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-idea-thread lia-fa-icon lia-fa-idea lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jul 2024 16:25:55 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Storing-data-tables-as-metadata-table-variables-JSL/m-p/769518#M95027</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2024-07-01T16:25:55Z</dc:date>
    </item>
  </channel>
</rss>

