キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 
  • JMP will suspend normal business operations for our Winter Holiday beginning on Wednesday, Dec. 24, 2025, at 5:00 p.m. ET (2:00 p.m. ET for JMP Accounts Receivable).
    Regular business hours will resume at 9:00 a.m. EST on Friday, Jan. 2, 2026.
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.

Discussions

Solve problems, and share tips and tricks with other JMP users.
言語を選択 翻訳バーを非表示
RobRobeyns
Level III

How to extract a report name in a generic way using jsl

Hi,

 

I would like to extract the report name using jsl. The script posted below is able to do so, but not for all types of reports. For example: I am able to extract the correct report name for a Graphbuilder report, but not for a Fit Manova report.

This results in an error: "Name Unresolved: rescript in access or evaluation of 'repscript', repscript/*###*/"

 

Is there a solution to make this script more generic/robust, so that it would work for all types of reports?

 

Names Default To Here(1);
dt=Current Data Table();
rep=Current Report();


//data table name
dtname=dt<<Get Name();
//Report title, Scriptable Object, and finally script of report in Char form
reptitle=rep<<get window title;
substitute into(reptitle,Eval(dtname)||" - ","");
//capture first word of reptitle
reptitlefw= word(1,reptitle," ");

report_type=reptitlefw||" ?";

//Eval(Parse(Eval Insert("repSO=rep[^(report_type)^]<<get scriptable object;")));

Try(Eval(Eval Expr(repSO=rep[Expr(report_type)]<<Get Scriptable Object));


repscript=Char(repSO<<get script));


//get array of row states
rowstates=dt<<get row states;

//script that sets row states to values in array
rowstatescript=Eval Insert(
"Names Default To Here(1);
dt=Current Data Table();

rowstates=^Char(rowstates)^;

for(i=1,i<=NRows(dt),i++,
Row State(dt,i)=As Row State(rowstates[i]);
);");


//save script for row states and report to data table
eval(parse("dt<<new script(reptitle,"||rowstatescript||repscript||")"));

Thanks!

 

1 件の受理された解決策

受理された解決策
txnelson
Super User

Re: How to extract a report name in a generic way using jsl

The issue with the JSL you have been using, is that not all window titles provide the correct information to get the Scriptable Object that can retrieve the Script.  I have found that using the initial Outline Box() from within the window is a more robust method.  However, it still will not work in all cases.  If a BY() group is specified, it will return the script for only the first BY() group.  Here is my modification to the code

Names Default To Here(1);
dt=Current Data Table();
rep=Current Report();


//data table name
dtname=dt<<Get Name();
//Report title, Scriptable Object, and finally script of report in Char form
reptitle=rep<<get window title;

// The Get Scriptable Object is a message available to the Report's
// initial Outline Box

repSO = window(reptitle)[outlinebox(1)]<<get Scriptable Object;

repscript=Char(repSO<<get script);

//get array of row states
rowstates=dt<<get row states;

//script that sets row states to values in array
rowstatescript=Eval Insert(
"Names Default To Here(1);
dt=Current Data Table();

rowstates=^Char(rowstates)^;

for(i=1,i<=NRows(dt),i++,
Row State(dt,i)=As Row State(rowstates[i]);
);");


//save script for row states and report to data table
eval(parse("dt<<new script(reptitle,"||rowstatescript||repscript||")"));
Jim

元の投稿で解決策を見る

3件の返信3

Re: How to extract a report name in a generic way using jsl

Hi,

I modified your script a bit so that it now gets the scriptable object from OutlineBox(1) of the current report, rather than trying to use the report name (see below).  Please try it out and let me know if it works for you.

 

Names Default To Here(1);
dt=Current Data Table();
rep=Current Report();

repSo=rep[OutlineBox(1)]<<Get Scriptable Object;
repscript=Char(repSO<<get script);

//data table name
dtname=dt<<Get Name();
//Report title, Scriptable Object, and finally script of report in Char form
reptitle=rep<<get window title;
substitute into(reptitle,Eval(dtname)||" - ","");

//get array of row states
rowstates=dt<<get row states;

//script that sets row states to values in array
rowstatescript=Eval Insert(
"Names Default To Here(1);
dt=Current Data Table();

rowstates=^Char(rowstates)^;

for(i=1,i<=NRows(dt),i++,
Row State(dt,i)=As Row State(rowstates[i]);
);");


//save script for row states and report to data table
eval(parse("dt<<new script(reptitle,"||rowstatescript||repscript||")"));
txnelson
Super User

Re: How to extract a report name in a generic way using jsl

The issue with the JSL you have been using, is that not all window titles provide the correct information to get the Scriptable Object that can retrieve the Script.  I have found that using the initial Outline Box() from within the window is a more robust method.  However, it still will not work in all cases.  If a BY() group is specified, it will return the script for only the first BY() group.  Here is my modification to the code

Names Default To Here(1);
dt=Current Data Table();
rep=Current Report();


//data table name
dtname=dt<<Get Name();
//Report title, Scriptable Object, and finally script of report in Char form
reptitle=rep<<get window title;

// The Get Scriptable Object is a message available to the Report's
// initial Outline Box

repSO = window(reptitle)[outlinebox(1)]<<get Scriptable Object;

repscript=Char(repSO<<get script);

//get array of row states
rowstates=dt<<get row states;

//script that sets row states to values in array
rowstatescript=Eval Insert(
"Names Default To Here(1);
dt=Current Data Table();

rowstates=^Char(rowstates)^;

for(i=1,i<=NRows(dt),i++,
Row State(dt,i)=As Row State(rowstates[i]);
);");


//save script for row states and report to data table
eval(parse("dt<<new script(reptitle,"||rowstatescript||repscript||")"));
Jim
RobRobeyns
Level III

Re: How to extract a report name in a generic way using jsl

Thanks for the solution Jim and Hadley!

Much appreciated!

おすすめの記事