JSL - How to get the type of AnalysisIs there an easy way to tell what type of analysis I'm looking at from a JSL perspective? I want to know if the outline box is a Oneway, Bivariate, ect. I thought there was an easy way to do this, like analysis << Class Name (but that didn't work - just returns OutlineBox).
I would like to run different code based on the type of analysis in any given window. This is assuming I don't explicitly create the analysis and know what it is. The only way I could think of is with the below code, but it feels incredibly glassy to me. Is this the only way?
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
analysis = dt << Fit Y by X(
Y( :weight ),
X( :height, :sex )
);
for(i=1, i<=nitems(analysis), i++,
if(contains(Log Capture(print(analysis[i])), "Oneway"),
Print("It's a Oneway"),
Print("It's not Oneway")
);
);
@Craige_Hales, @ms, @Jeff_Perkinson
Re: JSL - How to get the type of Analysisthanks @pmroz, yeah I often use the char() function similar to you, again, not sure why I didn't think of it in the moment.
The XPATH function appears super useful. The syntax doesn't appear too complicated and there's tutorials on W3schools, so that's a plus. https://www.w3schools.com/xml/xpath_intro.asp
Using XPATH I can just select the reports of the type I want. Super useful! Going to have to dig into this a bit.
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
analysis = dt << Fit Y by X(
Y( :weight ),
X( :height, :sex )
);
OnewayReports = Current report()<< xpath("//OutlineBox[contains(@helpKey, 'Oneway Report')]/.");
oneway = OnewayReports[1];
oneway << Set Title("Test");Re: JSL - How to get the type of AnalysisSorry, I was too quick to answer and did not really understand the question.
In the loop in your example Char(analysis[i]) would yield the same result as
Log Capture(Print(analysis[i])).
Also xpath() could be worth exploring for more complex scenarios. For example, this code example returns a list of strings from the current report.
Current report()<< xpath("//OutlineBox[contains(@helpKey, 'Report')]/@helpKey");Re: JSL - How to get the type of AnalysisGlad it helped. I've been using the char() function to convert things to text to write to Oracle, to save a dialog box state. In particular I've used it for lists. Note that doing things in reverse requires a parse.
a = {"xyz", "Hello", "World"};
b = char(a);
"{\!"xyz\!", \!"Hello\!", \!"World\!"}"
c = parse(b);
{"xyz", "Hello", "World"}
Re: JSL - How to get the type of AnalysisThanks! The obvious solution sometimes can escape you, I'm not sure where my mind was. I still wish the box object contained a name or type parameter.
Re: JSL - How to get the type of AnalysisHow about converting the analysis list to char and then parsing the result?
ca = char(analysis);
analysis_list = words(ca, "{}[], ");
{"Bivariate", "Oneway"}Re: JSL - How to get the type of AnalysisThis appears to just be returning the analysis object:
scriptObjs = analysis << get scriptable object;
print(scriptObjs);
print(analysis);
print(scriptObjs == analysis); //returns true
I'm still left with my log capture() method to scrape the scriptsObjs.
Re: JSL - How to get the type of Analysis
analysis << get scriptable object;
Returns a list of the analyses