<?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 Get entire contents of table script (including comments)? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Get-entire-contents-of-table-script-including-comments/m-p/364005#M61366</link>
    <description>&lt;P&gt;I am trying to come up with a system to organize all the JSL scripts attached to my data table.&amp;nbsp; I want to insert a header in the comments at the top of each of my scripts.&amp;nbsp; It will look like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;/* ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** 
 * Script Name:		my script name
 * Script Category:		&amp;lt;&amp;lt;category&amp;gt;&amp;gt;
 * Author:				author name
 * Rev Date:			date
 * Purpose:			purpose
 * * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * */&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Inside of this header I will keep some metadata about each of the scripts.&amp;nbsp; For example, the "script category" field which is enclosed in angle brackets.&amp;nbsp; I want to be able to iterate over the scripts and manipulate them based on this metadata.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know that I can obtain a list of all the scripts attached to my data table&amp;nbsp; like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Current Data Table();
scriptList = dt &amp;lt;&amp;lt; Get Table Script Names;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And then I can get the contents of a script like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;scriptText = Char(dt &amp;lt;&amp;lt; Get Table Property(scriptList[1]));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However, the scriptText does not contain any of the comments.&amp;nbsp; The header section is missing, so I can't access the metadata contained within those comments.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to get the&amp;nbsp;&lt;U&gt;full&lt;/U&gt; text of a table script, including comments?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 09 Jun 2023 22:07:13 GMT</pubDate>
    <dc:creator>Chris_Rodrigues</dc:creator>
    <dc:date>2023-06-09T22:07:13Z</dc:date>
    <item>
      <title>Get entire contents of table script (including comments)?</title>
      <link>https://community.jmp.com/t5/Discussions/Get-entire-contents-of-table-script-including-comments/m-p/364005#M61366</link>
      <description>&lt;P&gt;I am trying to come up with a system to organize all the JSL scripts attached to my data table.&amp;nbsp; I want to insert a header in the comments at the top of each of my scripts.&amp;nbsp; It will look like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;/* ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** 
 * Script Name:		my script name
 * Script Category:		&amp;lt;&amp;lt;category&amp;gt;&amp;gt;
 * Author:				author name
 * Rev Date:			date
 * Purpose:			purpose
 * * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * */&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Inside of this header I will keep some metadata about each of the scripts.&amp;nbsp; For example, the "script category" field which is enclosed in angle brackets.&amp;nbsp; I want to be able to iterate over the scripts and manipulate them based on this metadata.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know that I can obtain a list of all the scripts attached to my data table&amp;nbsp; like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Current Data Table();
scriptList = dt &amp;lt;&amp;lt; Get Table Script Names;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And then I can get the contents of a script like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;scriptText = Char(dt &amp;lt;&amp;lt; Get Table Property(scriptList[1]));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However, the scriptText does not contain any of the comments.&amp;nbsp; The header section is missing, so I can't access the metadata contained within those comments.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to get the&amp;nbsp;&lt;U&gt;full&lt;/U&gt; text of a table script, including comments?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 22:07:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Get-entire-contents-of-table-script-including-comments/m-p/364005#M61366</guid>
      <dc:creator>Chris_Rodrigues</dc:creator>
      <dc:date>2023-06-09T22:07:13Z</dc:date>
    </item>
    <item>
      <title>Re: Get entire contents of table script (including comments)?</title>
      <link>https://community.jmp.com/t5/Discussions/Get-entire-contents-of-table-script-including-comments/m-p/364048#M61369</link>
      <description>&lt;P&gt;The only way that I know of to kluge my way around this is to place each comment into a dummy literal string&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt=current data table();
eval(parse("\[dt &amp;lt;&amp;lt; new script("mysct", 
comment="/**************************************/";
names default to here(1);
dt=current data table();
comment="// Here come more comments";
;]\")); &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 01 Mar 2021 20:18:10 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Get-entire-contents-of-table-script-including-comments/m-p/364048#M61369</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2021-03-01T20:18:10Z</dc:date>
    </item>
    <item>
      <title>Re: Get entire contents of table script (including comments)?</title>
      <link>https://community.jmp.com/t5/Discussions/Get-entire-contents-of-table-script-including-comments/m-p/364125#M61374</link>
      <description>&lt;P&gt;Thanks.&amp;nbsp; That's what I was afraid of - there's no way to programmatically access the comments except using some kind of ugly kludge on the comments side of things.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did figure out a nicer-looking way to accomplish this.&amp;nbsp; I enclose the header comment block inside of JSL Quote() which tricks the JSL interpreter into keeping my comment block instead of deleting it.&amp;nbsp; So now I can read the category field and use it accordingly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's my example script:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;JSL Quote(
/* ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** 
 * Script Name:			my script name
 * Script Category:		&amp;lt;&amp;lt;my category&amp;gt;&amp;gt;
 * Author:				author name
 * Rev Date:			date
 * Purpose:				purpose
 * * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * */
);

//this comment will be deleted

dt = Current Data Table();
scriptText = Char(dt &amp;lt;&amp;lt; Get Table Property("my script name"));
scriptCategory = Char(Regex(scriptText,"\&amp;lt;\&amp;lt;([A-Za-z0-9 \/]*)\&amp;gt;\&amp;gt;", "\1"));
Write("\!n" || scriptText || "\!n");
Write("\!n" || scriptCategory || "\!n");&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;And the output to the log:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;JSL Quote(
/* ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** 
 * Script Name:			my script name
 * Script Category:		&amp;lt;&amp;lt;my category&amp;gt;&amp;gt;
 * Author:				author name
 * Rev Date:			date
 * Purpose:				purpose
 * * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * ** * */
); dt = Current Data Table(); scriptText = Char(dt &amp;lt;&amp;lt; Get Table Property("my script name")); scriptCategory = Char(Regex(scriptText, "\&amp;lt;\&amp;lt;([A-Za-z0-9 \/]*)\&amp;gt;\&amp;gt;", "\1")); Write("
" || scriptText || "
"); Write("
" || scriptCategory || "
")

my category&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Mar 2021 21:57:04 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Get-entire-contents-of-table-script-including-comments/m-p/364125#M61374</guid>
      <dc:creator>Chris_Rodrigues</dc:creator>
      <dc:date>2021-03-01T21:57:04Z</dc:date>
    </item>
  </channel>
</rss>

