I use self-contained journal files for demos and training, making them easy to share. Links to close individual sections and to clean up everything keeps things moving. The script below creates a basic example journal; once you run it, you should see a journal with links in it. Right click on each and select Edit > Edit Script to see how they are constructed. I use 'Copy Table Script' often to populate these. Putting this codes in functions is a good idea, but be mindful of it looking more like black magic to beginning users who try to explore your journal.
Note that I normally make journals interactively, not using a script like this.
names default to here(1);
//Open data tables temporarily so we can copy their scripts
dtIrisTemp = open("$Sample_Data/Iris.jmp");
dtBigClassTemp = open("$Sample_Data/Big Class.jmp");
//Use Eval(EvalExpr()) so the actual scripts for the data table are saved in
//the journal.
Eval( Eval Expr(
journal = New Window( "A Journal", <<Journal,
V List Box(
Outline Box( "Distributions",
Text Box( "JMP can show the distribution of data values."),
H List Box(
//Open the table or bring it forward if it is already open
Button Box( "Iris Data",
Try(
dtIris << Bring Window to Front();
,
dtIris = expr( dtIrisTemp << Get Script() );
)
, << Underline Style(1)
),
//Button to close the table
Button Box( "<< Close",
Try(dtIris << Close Window)
, << Underline Style(1)
)
),
Button Box( "A Distribution",
Try(dtIris << Distribution(
Continuous Distribution( Column( :Sepal length ) ),
Continuous Distribution( Column( :Sepal width ) )
))
, << Underline Style(1)
)
),
Outline Box( "Graphs",
Text Box( "JMP can make graphs."),
H List Box(
//Open the table or bring it forward if it is already open
Button Box( "Big Class Data",
Try(
dtBigClass << Bring Window to Front();
,
dtBigClass = expr( dtBigClassTemp << Get Script() );
)
, << Underline Style(1)
),
//Button to close the table
Button Box( "<< Close",
Try(dtBigClass << Close Window)
, << Underline Style(1)
)
),
Button Box( "A Graph",
Try(dtBigClass << Graph Builder(
Show Control Panel( 0 ),
Variables( X( :weight ), Y( :height ) ),
Elements( Points( X, Y, Legend( 6 ) ) )
))
, << Underline Style(1)
)
),
Button Box( "Clean Up - Close Everything",
Try(
dtIris << Close Window;
dtBigClass << Close Window;
)
, << Underline Style(1)
)
)
);
) );
dtIrisTemp << Close Window;
dtBigClassTemp << Close Window;