<?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: talk to enhanced log in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/talk-to-enhanced-log/m-p/774370#M95606</link>
    <description>&lt;P&gt;Enhanced Log is inside window called Log (if you are using enhanced log), from there you can use show properties and figure out that there is table box which contains a lot of different things&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

elog = Window("Log")[Table Box(1)] &amp;lt;&amp;lt; get;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 20 Jul 2024 15:44:38 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2024-07-20T15:44:38Z</dc:date>
    <item>
      <title>talk to enhanced log</title>
      <link>https://community.jmp.com/t5/Discussions/talk-to-enhanced-log/m-p/774358#M95604</link>
      <description>&lt;P&gt;The enhanced log knows which command is sent to which data table and indicates the source and output data tables and reports&amp;nbsp; with different colors. The icons can be used to bring the respective window to the front:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hogi_1-1721489134825.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/66342iA482823C7D8E31BC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="hogi_1-1721489134825.png" alt="hogi_1-1721489134825.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Is there a JSL functionality that allows me to talk to the &lt;STRONG&gt;enhanced log&lt;/STRONG&gt;?&lt;/P&gt;&lt;P&gt;like&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;log &amp;lt;&amp;lt; list commands(10);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;to get the last 10 commands.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;or &lt;CODE class=" language-jsl"&gt;log &amp;lt;&amp;lt; list commands("3h");&lt;/CODE&gt;&amp;nbsp;for the commands of the last 3 hours?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;or&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;log &amp;lt;&amp;lt; list commands(data table(dt));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;to get all commands which were triggered with target data table &lt;FONT face="courier new,courier"&gt;dt&lt;/FONT&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 20 Jul 2024 15:27:31 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/talk-to-enhanced-log/m-p/774358#M95604</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2024-07-20T15:27:31Z</dc:date>
    </item>
    <item>
      <title>Re: talk to enhanced log</title>
      <link>https://community.jmp.com/t5/Discussions/talk-to-enhanced-log/m-p/774370#M95606</link>
      <description>&lt;P&gt;Enhanced Log is inside window called Log (if you are using enhanced log), from there you can use show properties and figure out that there is table box which contains a lot of different things&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

elog = Window("Log")[Table Box(1)] &amp;lt;&amp;lt; get;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 20 Jul 2024 15:44:38 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/talk-to-enhanced-log/m-p/774370#M95606</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-07-20T15:44:38Z</dc:date>
    </item>
    <item>
      <title>Re: talk to enhanced log</title>
      <link>https://community.jmp.com/t5/Discussions/talk-to-enhanced-log/m-p/774387#M95608</link>
      <description>&lt;P&gt;cool!&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;done&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;collect table creation script, editing scripts and report creation script from enhanced log&lt;/LI&gt;&lt;LI&gt;get the original data table via the enhanced log to save the final script&lt;/LI&gt;&lt;LI&gt;replace original table name with&amp;nbsp; variable &lt;FONT face="courier new,courier"&gt;mydt&amp;nbsp;&lt;/FONT&gt; to counteract table name collisions&lt;BR /&gt;[-&amp;gt; my suggestion for Workflow Builder]&lt;/LI&gt;&lt;LI&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;remove duplicate/template messages&lt;/FONT&gt;&lt;/LI&gt;&lt;LI&gt;multiple data tables with the same name? assume that the last one is the right&lt;/LI&gt;&lt;LI&gt;reports with/without data filter&lt;/LI&gt;&lt;LI&gt;StealThisCode can be used iteratively to optimize the report and save it again&lt;BR /&gt;[similar to: save script to data table - run - edit - save script to data table ....]&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;todo:&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;debugging&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;then I will upload the new version ...&lt;BR /&gt;&amp;nbsp;&lt;LI-MESSAGE title="Graph Builder Toolbar" uid="565466" url="https://community.jmp.com/t5/JMP-Add-Ins/Graph-Builder-Toolbar/m-p/565466#U565466" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-tkb-thread lia-fa-icon lia-fa-tkb lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;this is how it could look like:&lt;/P&gt;&lt;P&gt;&lt;div class="lia-vid-container video-embed-center"&gt;&lt;div id="lia-vid-6358996742112w920h540r674" class="lia-video-brightcove-player-container"&gt;&lt;video-js data-video-id="6358996742112" data-account="6058004218001" data-player="default" data-embed="default" class="vjs-fluid" controls="" data-application-id="" style="width: 100%; height: 100%;"&gt;&lt;/video-js&gt;&lt;/div&gt;&lt;script src="https://players.brightcove.net/6058004218001/default_default/index.min.js"&gt;&lt;/script&gt;&lt;script&gt;(function() {  var wrapper = document.getElementById('lia-vid-6358996742112w920h540r674');  var videoEl = wrapper ? wrapper.querySelector('video-js') : null;  if (videoEl) {     if (window.videojs) {       window.videojs(videoEl).ready(function() {         this.on('loadedmetadata', function() {           this.el().querySelectorAll('.vjs-load-progress div[data-start]').forEach(function(bar) {             bar.setAttribute('role', 'presentation');             bar.setAttribute('aria-hidden', 'true');           });         });       });     }  }})();&lt;/script&gt;&lt;a class="video-embed-link" href="https://community.jmp.com/t5/video/gallerypage/video-id/6358996742112"&gt;(view in My Videos)&lt;/a&gt;&lt;/div&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;current version:&lt;/P&gt;&lt;LI-SPOILER&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// autor: Holger Specht (hogi)
// extension of https://community.jmp.com/t5/Discovery-Summit-Americas-2021/Steal-This-Code-Three-Upgrades-for-Scripts-Obtained-from-the/ta-p/398700
// the idea:
// - starting from a report
// - use the enhanced log to collect all processing steps which lead from a saved ("original") data table to the report
// - postprocess the steps to get a robus script
// - save the script to the origial data table 


Names Default To Here( 1 );


show info = Function( {},
	Caption( "please create a graph from a summary/subset table and run this script again. Add as many intermediate steps as you want  :)" );
	Stop();
);


Try(
	If( Current Report()[Outline Box( 1 )] &amp;lt;&amp;lt; Get Title() == "Local Data Filter",
		myScriptableObject = (Current Report()[Outline Box( 2 )] &amp;lt;&amp;lt; Get Scriptable Object()),
		myScriptableObject = (Current Report()[Outline Box( 1 )] &amp;lt;&amp;lt; Get Scriptable Object())
	),
	showInfo()
);
mydt = myScriptableObject &amp;lt;&amp;lt; Get Data Table();
myWindowName = (mydt &amp;lt;&amp;lt; Get Window()) &amp;lt;&amp;lt; get window title();

//developer is here =1;
elog = Window( "Log" )[Table Box( 1 )] &amp;lt;&amp;lt; make into data table(private( 1 ) );
rowCreated = Eval( Eval Expr( Where( elog, :Result == "Data Table( \!"" || Expr( myWindowName ) || "\!" )" ) ) );

nr = N Items( rowCreated );

If( nr == 0 &amp;amp; N Items( Current Report() &amp;lt;&amp;lt; XPath( "//PanelBox[text()='//steal this code']" ) ) == 0,
	show info()
);


// if the current report is already created via stealThisCode, get the saved infos
If( N Items( Current Report() &amp;lt;&amp;lt; XPath( "//PanelBox[text()='//steal this code']" ) ),
	dtOrig = (Eval( Parse( Current Report()[Text Box( 1 )] &amp;lt;&amp;lt; get text  )) );
	myScript = Parse( Current Report() [Text Box( 2 )] &amp;lt;&amp;lt; get text);
	
	// if a data table was created with the same name, we have to get rid of the wrong log entries -&amp;gt; search for steal this code!
	rowcreated =  Where( elog, :Message == "\!"steal this code\!"" );
	nr = N Items( rowCreated );
	rowcreated = rowcreated[{nr}]
, // otherwise: get the original data table from the log and start with a draft data table
 
	// the user created multiple data table with the same name? the last one might be the correct one ?!?!
	rowcreated = rowcreated[{nr}];

// select the right actions
	
	Window( "Log" )[Table Box( 1 )] &amp;lt;&amp;lt; Set Selected Rows( rowCreated );

// get script from the log and remove the comment block
	myScript = Parse( Substitute( Window( "Log" )[Script Box( 1 )] &amp;lt;&amp;lt; get text, "/*:", "" ) );

	dtOrig = Arg( myScript, 1 );
	myScript = Substitute(
			Expr(
				Names Default To Here( 1 );
				//marks the start of the execution in the log
				Print("steal this code");
				mydt = _x_;
			),
		Expr( _x_ ), Name Expr( myScript )
	);
);


Eval( Eval Expr( myRows = elog &amp;lt;&amp;lt; get rows where( :Origin == "Window( \!"" || Expr( myWindowName ) || "\!" )" &amp;amp; Row() &amp;gt; Expr( rowCreated ) ) ) );
if (N Items(myRows),
Window( "Log" )[Table Box( 1 )] &amp;lt;&amp;lt; Set Selected Rows( myRows );

mydtch = Substitute( Char( mydt ), "DataTable(", "Data Table( ", ")", " )" );
myscript2 = Window( "Log" )[Script Box( 1 )] &amp;lt;&amp;lt; get text;
myScript2 = Parse( Substitute(myscript2 , "/*:", "", mydtch, "mydt" ) ); // substitute get noch nicht
Insert Into( myScript, Name Expr( myScript2 ) ));

//I got all infos from the log
Close( elog, noSave );

reports = Associative Array(
	Eval List( {Name Expr( Graph Builder() ), Name Expr( Distribution() ), Name Expr( Fit Model() )} ),
	{1, 1, 1},
	&amp;lt;&amp;lt;set default value( 0 )
);

//remove the useless GraphBuilder Template
For( i = 1, i &amp;lt;= N Arg( myScript ), i++,
	If( reports[Head( Arg( Arg( myScript, i ), 2 ) )],
		Substitute Into( myScript, Arg( myScript, i ), 1 )
	)
);

myReportScript = myScriptableObject &amp;lt;&amp;lt; get script();

// wrap the report script and add/hide some info for later
myReportScript = Substitute(
		Expr(
			New Window( "",
				V List Box(
					Panel Box( "//steal this code",
						&amp;lt;&amp;lt;visibility( "Collapse" ),
						Text Box( _dtorig_ ),
						Text Box( _code_ )
	
					),
					_myReportScript_
				)
			)
		),
	Expr( _myReportScript_ ), Name Expr( myReportScript ),
	Expr( _dtorig_ ), Char( dtOrig ),
	Expr( _code_ ), Char( Name Expr( myScript ) )
);


Insert Into( myScript, Name Expr( myReportScript ) );


// add the generated script to the original table
Eval( Substitute( Expr( dtOrig &amp;lt;&amp;lt; New Script( "combined script", _code_ ) ), Expr( _code_ ), Name Expr( myScript ) ) );

dtOrig &amp;lt;&amp;lt; Bring Window To Front;

Caption( "find the new script and run it ..." );
wait(0.5);
Caption(remove)
//New window("test",&amp;lt;&amp;lt; Type("Script"),Char(Name Expr(myScript)))&lt;/CODE&gt;&lt;/PRE&gt;&lt;/LI-SPOILER&gt;</description>
      <pubDate>Wed, 24 Jul 2024 14:56:32 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/talk-to-enhanced-log/m-p/774387#M95608</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2024-07-24T14:56:32Z</dc:date>
    </item>
    <item>
      <title>Re: talk to enhanced log</title>
      <link>https://community.jmp.com/t5/Discussions/talk-to-enhanced-log/m-p/794673#M97142</link>
      <description>&lt;P&gt;beta version added now to&amp;nbsp;&lt;LI-MESSAGE title="Graph Builder Toolbar" uid="565466" url="https://community.jmp.com/t5/JMP-Add-Ins/Graph-Builder-Toolbar/m-p/565466#U565466" discussion_style_icon_css="lia-mention-container-editor-message lia-img-icon-tkb-thread lia-fa-icon lia-fa-tkb lia-fa-thread lia-fa"&gt;&lt;/LI-MESSAGE&gt;&amp;nbsp;:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hogi_0-1725394903574.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/67856i6A5E5DA29877BDAE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="hogi_0-1725394903574.png" alt="hogi_0-1725394903574.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Sep 2024 20:21:51 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/talk-to-enhanced-log/m-p/794673#M97142</guid>
      <dc:creator>hogi</dc:creator>
      <dc:date>2024-09-03T20:21:51Z</dc:date>
    </item>
  </channel>
</rss>

