<?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 JSL Script to combine reports into a single journal - broken in 19 - What is wrong with my ugly script? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/JSL-Script-to-combine-reports-into-a-single-journal-broken-in-19/m-p/907278#M106564</link>
    <description>&lt;P&gt;I have a monthly run of capability reports to run, and the internal customer really likes the Capability Explorer from the marketplace - and why not it's really good. My problem is I have 60 individual reports to collate (it makes one per column) - So I wrote (hacked) this JSL which collected selected reports into a journal that I could export to a pdf - it all worked fine (apart from the auto-close windows option - I gave up on that) but fails since I updated to 19.&amp;nbsp; The error (at least the first error!) is&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Expected platform argument in access or evaluation of 'Report' , Bad Argument( w ), Report/*###*/(w)&lt;/P&gt;
&lt;P&gt;at line 92 in pathGoesHere\Chooser and PDF export v2.jsl&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I'd really appreciate some help or pointers.&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// ===== BEGIN: Select windows and export a single combined PDF (with headers/footers &amp;amp; page breaks) =====
Names Default To Here( 1 );

// -------------------- User Controls --------------------
allowCloseDataTables   = 1;   // 0 = keep Data Table windows open (safe), 1 = allow closing them
forceCloseNoPrompt     = 0;   // 1 = Close(..., No Save) for hands‑free; 0 = allow Save prompts (may block)

// -------------------- Summary Counters --------------------
closedCount            = 0;
attemptedCount         = 0;
failedCount            = 0;
skippedDTCount         = 0;
skippedJournalCount    = 0;

// -------------------- 1) Collect open windows (JMP 18 reliable) --------------------
winRefs   = Get Window List();    // list of top-level window handles
winTitles = {};

// Build clean titles for the list (characters only)
For( i = 1, i &amp;lt;= N Items( winRefs ), i++,
    w = winRefs[i];
    t = "Window " || Char( i );
    Try(
        t0 = w &amp;lt;&amp;lt; Get Window Title;
        t  = Char( t0 );
        If( Is Empty( t ), t = "Window " || Char( i ) );
    );
    Insert Into( winTitles, t );
);

// -------------------- 2) Dialog: pick windows + optional "close after export" --------------------
selIdx     = {};
closeAfter = 0;

New Window( "Select windows to include", &amp;lt;&amp;lt;Modal,
    V List Box(
        Text Box( "Ctrl/Cmd + click to multi-select" ),
        lb = List Box( winTitles, Max Selected( 999 ) ),
        cb = Check Box( { "Close selected windows after export" } ),
        H List Box(
            Button Box( "OK",
                selIdx     = lb &amp;lt;&amp;lt; Get Selected Indices;              // indices map to winRefs
                closeAfter = N Items( cb &amp;lt;&amp;lt; Get Selected ) &amp;gt; 0;
            ),
            Spacer Box( Size( 12, 0 ) ),
            Button Box( "Cancel",
                selIdx     = {};
                closeAfter = 0;
            )
        )
    )
);

If( N Items( selIdx ) == 0,
    Throw( "No windows selected." )
);

// -------------------- 3) Build a list of Data Table windows (no probing on random windows) --------------------
dtWinRefs = {};
nt = N Table();
For( i = 1, i &amp;lt;= nt, i++,
    dt = Data Table( i );
    Try(
        dtw = dt &amp;lt;&amp;lt; Get Window;                      // window that hosts this Data Table
        If( !Is Empty( dtw ),
            Insert Into( dtWinRefs, dtw );
        );
    );
);

// -------------------- 4) Build the combined journal with static content --------------------
jnw = New Window( "Combined Report", &amp;lt;&amp;lt;Journal );    // keep handle so we don't close it
jrn = Current Journal();                              // Journal display box

// Page break control
nSel = N Items( selIdx );
idx  = 1;

For Each( {k}, selIdx,
    w = winRefs[k];
    If( Is Empty( w ), Continue() );  // Safety: skip if null

    // Safe title (character) for the section
    titleTxt = "Untitled";
    Try(
        tmp = w &amp;lt;&amp;lt; Get Window Title;
        titleTxt = Char( tmp );
        If( Is Empty( titleTxt ), titleTxt = "Untitled" );
    );

    // Prefer a cloned report; fall back to a snapshot
    rb = Report( w );
    content = Picture Box( w &amp;lt;&amp;lt; Get Picture );        // snapshot by default
    If( !Is Empty( rb ),
        Try( content = rb &amp;lt;&amp;lt; Clone Box; );            // upgrade to cloned report if possible
    );

    // Append a section with page spacing
    sec = V List Box(
        Outline Box( titleTxt, content ),
        Spacer Box( Size( 0, 12 ) )
    );
    jrn &amp;lt;&amp;lt; Append( sec );

    // Add a page break AFTER each section except the last
    If( idx &amp;lt; nSel,
        sec &amp;lt;&amp;lt; Page Break;
    );
    idx++;

    // -------------------- 5) Optional: close the original window --------------------
    If( closeAfter,
    // I've added in a simple close window option here that can hopefully be applied

Show(selIdx);					//Just here to check that the indices are being recorded as expected

Test = winTitles[selIdx];		//Creating the imaginatively named "test" variable that creates a subset of teh window names we want to close

Show(Test);						//Just checking that this is behaving as expected


// Creating the logic to iterate throgh the list of selected windows and closing them in turn

For (i=1, i&amp;lt;= N items(Test),i++,
	Window (Test[i]) &amp;lt;&amp;lt; close window	
);

/*
        // (a) Is this window one of the known Data Table windows?
        isDT = 0;
        For( ii = 1, ii &amp;lt;= N Items( dtWinRefs ), ii++,
            If( w == dtWinRefs[ii],
                isDT = 1;
                Break();
            );
        );

        // (b) Decide whether to close
        // Keep the newly-created journal open; optionally skip DT windows depending on the toggle
        willClose = (w != jnw) &amp;amp; ( (!isDT) | allowCloseDataTables );

        // (c) Diagnostics
        Show(
            "DECISION | title='" || titleTxt ||
            "' | isDT=" || Char( isDT ) ||
            " | isJournal=" || Char( w == jnw ) ||
            " | allowCloseDataTables=" || Char( allowCloseDataTables ) ||
            " | willClose=" || Char( willClose )
        );

        // (d) Attempt closure (two strategies)
        If( willClose,
            attemptedCount++;
            closedOK = 0;

            // Prefer direct Close (No Save for hands-free automation)
            If( forceCloseNoPrompt,
                Try( Close( w, No Save ); closedOK = 1, closedOK = 0 );
            ,
                Try( Close( w );          closedOK = 1, closedOK = 0 );
            );

            // Fallback: some windows prefer the window-message style
            If( !closedOK,
                Try( w &amp;lt;&amp;lt; Close Window;   closedOK = 1, closedOK = 0 );
            );

            If( closedOK,
                closedCount++,
                failedCount++
            );
        ,
            // Not closing: count reasons
            If( w == jnw,
                skippedJournalCount++,
                If( isDT, skippedDTCount++ )
            );*/
        );
    );


// -------------------- 6) Headers, footers, page setup, export --------------------
ts = Format( Today(), "yyyy-mm-dd hh:mm" );

// Set print headers/footers (Left, Center, Right)
jrn &amp;lt;&amp;lt; Set Print Headers(
    "JMP Combined Report",
    "Selected Windows",
    "Generated: " || ts
);

jrn &amp;lt;&amp;lt; Set Print Footers(
    "",
    "",
    "Confidential"
);

// Page setup for the whole PDF
jrn &amp;lt;&amp;lt; Set Page Setup(
    Margins( 0.5, 0.5, 0.5, 0.5 ),
    Scale( 0.58 ),              // &amp;lt;&amp;lt; scale as requested
    Portrait( 0 ),              // 0 = Landscape, 1 = Portrait
    Paper Size( "A4" )
);

// Save location (Desktop by default)
outPath = "$DESKTOP/Selected_Windows.pdf";

// If you prefer a Save As... dialog, uncomment below:
// outPath = Pick File( "Save combined PDF as", "$DESKTOP", {"PDF Files|*.pdf"}, 1, "Selected_Windows.pdf" );
// If( Is Empty( outPath ), Throw( "Save cancelled." ) );

jrn &amp;lt;&amp;lt; Save PDF( outPath, Show Page Setup( 0 ) );    // quiet export (no Page Setup dialog)

// -------------------- 7) Notifications &amp;amp; Close Summary --------------------
Show( "Combined PDF written to: " || outPath, "Closed after export: " || Char( closeAfter ) );

Show(
    "Close Summary | attempted=" || Char( attemptedCount ) ||
    ", closed=" || Char( closedCount ) ||
    ", failed=" || Char( failedCount ) ||
    ", skippedDT=" || Char( skippedDTCount ) ||
    ", skippedJournal=" || Char( skippedJournalCount )
);

Beep();

// ===== END =====
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 13 Oct 2025 14:03:21 GMT</pubDate>
    <dc:creator>NeillSM</dc:creator>
    <dc:date>2025-10-13T14:03:21Z</dc:date>
    <item>
      <title>JSL Script to combine reports into a single journal - broken in 19 - What is wrong with my ugly script?</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Script-to-combine-reports-into-a-single-journal-broken-in-19/m-p/907278#M106564</link>
      <description>&lt;P&gt;I have a monthly run of capability reports to run, and the internal customer really likes the Capability Explorer from the marketplace - and why not it's really good. My problem is I have 60 individual reports to collate (it makes one per column) - So I wrote (hacked) this JSL which collected selected reports into a journal that I could export to a pdf - it all worked fine (apart from the auto-close windows option - I gave up on that) but fails since I updated to 19.&amp;nbsp; The error (at least the first error!) is&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;Expected platform argument in access or evaluation of 'Report' , Bad Argument( w ), Report/*###*/(w)&lt;/P&gt;
&lt;P&gt;at line 92 in pathGoesHere\Chooser and PDF export v2.jsl&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I'd really appreciate some help or pointers.&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// ===== BEGIN: Select windows and export a single combined PDF (with headers/footers &amp;amp; page breaks) =====
Names Default To Here( 1 );

// -------------------- User Controls --------------------
allowCloseDataTables   = 1;   // 0 = keep Data Table windows open (safe), 1 = allow closing them
forceCloseNoPrompt     = 0;   // 1 = Close(..., No Save) for hands‑free; 0 = allow Save prompts (may block)

// -------------------- Summary Counters --------------------
closedCount            = 0;
attemptedCount         = 0;
failedCount            = 0;
skippedDTCount         = 0;
skippedJournalCount    = 0;

// -------------------- 1) Collect open windows (JMP 18 reliable) --------------------
winRefs   = Get Window List();    // list of top-level window handles
winTitles = {};

// Build clean titles for the list (characters only)
For( i = 1, i &amp;lt;= N Items( winRefs ), i++,
    w = winRefs[i];
    t = "Window " || Char( i );
    Try(
        t0 = w &amp;lt;&amp;lt; Get Window Title;
        t  = Char( t0 );
        If( Is Empty( t ), t = "Window " || Char( i ) );
    );
    Insert Into( winTitles, t );
);

// -------------------- 2) Dialog: pick windows + optional "close after export" --------------------
selIdx     = {};
closeAfter = 0;

New Window( "Select windows to include", &amp;lt;&amp;lt;Modal,
    V List Box(
        Text Box( "Ctrl/Cmd + click to multi-select" ),
        lb = List Box( winTitles, Max Selected( 999 ) ),
        cb = Check Box( { "Close selected windows after export" } ),
        H List Box(
            Button Box( "OK",
                selIdx     = lb &amp;lt;&amp;lt; Get Selected Indices;              // indices map to winRefs
                closeAfter = N Items( cb &amp;lt;&amp;lt; Get Selected ) &amp;gt; 0;
            ),
            Spacer Box( Size( 12, 0 ) ),
            Button Box( "Cancel",
                selIdx     = {};
                closeAfter = 0;
            )
        )
    )
);

If( N Items( selIdx ) == 0,
    Throw( "No windows selected." )
);

// -------------------- 3) Build a list of Data Table windows (no probing on random windows) --------------------
dtWinRefs = {};
nt = N Table();
For( i = 1, i &amp;lt;= nt, i++,
    dt = Data Table( i );
    Try(
        dtw = dt &amp;lt;&amp;lt; Get Window;                      // window that hosts this Data Table
        If( !Is Empty( dtw ),
            Insert Into( dtWinRefs, dtw );
        );
    );
);

// -------------------- 4) Build the combined journal with static content --------------------
jnw = New Window( "Combined Report", &amp;lt;&amp;lt;Journal );    // keep handle so we don't close it
jrn = Current Journal();                              // Journal display box

// Page break control
nSel = N Items( selIdx );
idx  = 1;

For Each( {k}, selIdx,
    w = winRefs[k];
    If( Is Empty( w ), Continue() );  // Safety: skip if null

    // Safe title (character) for the section
    titleTxt = "Untitled";
    Try(
        tmp = w &amp;lt;&amp;lt; Get Window Title;
        titleTxt = Char( tmp );
        If( Is Empty( titleTxt ), titleTxt = "Untitled" );
    );

    // Prefer a cloned report; fall back to a snapshot
    rb = Report( w );
    content = Picture Box( w &amp;lt;&amp;lt; Get Picture );        // snapshot by default
    If( !Is Empty( rb ),
        Try( content = rb &amp;lt;&amp;lt; Clone Box; );            // upgrade to cloned report if possible
    );

    // Append a section with page spacing
    sec = V List Box(
        Outline Box( titleTxt, content ),
        Spacer Box( Size( 0, 12 ) )
    );
    jrn &amp;lt;&amp;lt; Append( sec );

    // Add a page break AFTER each section except the last
    If( idx &amp;lt; nSel,
        sec &amp;lt;&amp;lt; Page Break;
    );
    idx++;

    // -------------------- 5) Optional: close the original window --------------------
    If( closeAfter,
    // I've added in a simple close window option here that can hopefully be applied

Show(selIdx);					//Just here to check that the indices are being recorded as expected

Test = winTitles[selIdx];		//Creating the imaginatively named "test" variable that creates a subset of teh window names we want to close

Show(Test);						//Just checking that this is behaving as expected


// Creating the logic to iterate throgh the list of selected windows and closing them in turn

For (i=1, i&amp;lt;= N items(Test),i++,
	Window (Test[i]) &amp;lt;&amp;lt; close window	
);

/*
        // (a) Is this window one of the known Data Table windows?
        isDT = 0;
        For( ii = 1, ii &amp;lt;= N Items( dtWinRefs ), ii++,
            If( w == dtWinRefs[ii],
                isDT = 1;
                Break();
            );
        );

        // (b) Decide whether to close
        // Keep the newly-created journal open; optionally skip DT windows depending on the toggle
        willClose = (w != jnw) &amp;amp; ( (!isDT) | allowCloseDataTables );

        // (c) Diagnostics
        Show(
            "DECISION | title='" || titleTxt ||
            "' | isDT=" || Char( isDT ) ||
            " | isJournal=" || Char( w == jnw ) ||
            " | allowCloseDataTables=" || Char( allowCloseDataTables ) ||
            " | willClose=" || Char( willClose )
        );

        // (d) Attempt closure (two strategies)
        If( willClose,
            attemptedCount++;
            closedOK = 0;

            // Prefer direct Close (No Save for hands-free automation)
            If( forceCloseNoPrompt,
                Try( Close( w, No Save ); closedOK = 1, closedOK = 0 );
            ,
                Try( Close( w );          closedOK = 1, closedOK = 0 );
            );

            // Fallback: some windows prefer the window-message style
            If( !closedOK,
                Try( w &amp;lt;&amp;lt; Close Window;   closedOK = 1, closedOK = 0 );
            );

            If( closedOK,
                closedCount++,
                failedCount++
            );
        ,
            // Not closing: count reasons
            If( w == jnw,
                skippedJournalCount++,
                If( isDT, skippedDTCount++ )
            );*/
        );
    );


// -------------------- 6) Headers, footers, page setup, export --------------------
ts = Format( Today(), "yyyy-mm-dd hh:mm" );

// Set print headers/footers (Left, Center, Right)
jrn &amp;lt;&amp;lt; Set Print Headers(
    "JMP Combined Report",
    "Selected Windows",
    "Generated: " || ts
);

jrn &amp;lt;&amp;lt; Set Print Footers(
    "",
    "",
    "Confidential"
);

// Page setup for the whole PDF
jrn &amp;lt;&amp;lt; Set Page Setup(
    Margins( 0.5, 0.5, 0.5, 0.5 ),
    Scale( 0.58 ),              // &amp;lt;&amp;lt; scale as requested
    Portrait( 0 ),              // 0 = Landscape, 1 = Portrait
    Paper Size( "A4" )
);

// Save location (Desktop by default)
outPath = "$DESKTOP/Selected_Windows.pdf";

// If you prefer a Save As... dialog, uncomment below:
// outPath = Pick File( "Save combined PDF as", "$DESKTOP", {"PDF Files|*.pdf"}, 1, "Selected_Windows.pdf" );
// If( Is Empty( outPath ), Throw( "Save cancelled." ) );

jrn &amp;lt;&amp;lt; Save PDF( outPath, Show Page Setup( 0 ) );    // quiet export (no Page Setup dialog)

// -------------------- 7) Notifications &amp;amp; Close Summary --------------------
Show( "Combined PDF written to: " || outPath, "Closed after export: " || Char( closeAfter ) );

Show(
    "Close Summary | attempted=" || Char( attemptedCount ) ||
    ", closed=" || Char( closedCount ) ||
    ", failed=" || Char( failedCount ) ||
    ", skippedDT=" || Char( skippedDTCount ) ||
    ", skippedJournal=" || Char( skippedJournalCount )
);

Beep();

// ===== END =====
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Oct 2025 14:03:21 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Script-to-combine-reports-into-a-single-journal-broken-in-19/m-p/907278#M106564</guid>
      <dc:creator>NeillSM</dc:creator>
      <dc:date>2025-10-13T14:03:21Z</dc:date>
    </item>
    <item>
      <title>Re: JSL Script to combine reports into a single journal - broken in 19 - What is wrong with my ugly script?</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Script-to-combine-reports-into-a-single-journal-broken-in-19/m-p/907292#M106565</link>
      <description>&lt;P&gt;Seems like JMP19 has changed what happens when you try to use Report function on New Window: In JMP18 it will return missing value and in JMP19 it will throw an error you are seeing. There are many options you could do, but maybe something like is enough: Add Try() to your line 92&lt;/P&gt;
&lt;P&gt;Original:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1760365764057.png" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/84932i9140CE4BC843EA78/image-size/large?v=v2&amp;amp;px=999" role="button" title="jthi_0-1760365764057.png" alt="jthi_0-1760365764057.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Modified&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;rb = Try(Report(w), .);
content = Picture Box(w &amp;lt;&amp;lt; Get Picture);
If(!Is Empty(rb),
	Try(content = rb &amp;lt;&amp;lt; Clone Box);            // upgrade to cloned report if possible
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Oct 2025 14:30:01 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Script-to-combine-reports-into-a-single-journal-broken-in-19/m-p/907292#M106565</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2025-10-13T14:30:01Z</dc:date>
    </item>
    <item>
      <title>Re: JSL Script to combine reports into a single journal - broken in 19 - What is wrong with my ugly script?</title>
      <link>https://community.jmp.com/t5/Discussions/JSL-Script-to-combine-reports-into-a-single-journal-broken-in-19/m-p/907758#M106597</link>
      <description>&lt;P&gt;Thank you for that - I'm still getting to grips with JSL - Try() is a very new concept for me.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Oct 2025 08:19:33 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/JSL-Script-to-combine-reports-into-a-single-journal-broken-in-19/m-p/907758#M106597</guid>
      <dc:creator>NeillSM</dc:creator>
      <dc:date>2025-10-15T08:19:33Z</dc:date>
    </item>
  </channel>
</rss>

