cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
lenny
Level II

Create an open file button using a variable.

I have a report that generates several graphs and saves the raw data tables used for each graph as a file a using a different variable as part of the naming convention.

I want to add a button to each graph so that you can open the raw data.Is there a way to create a button that will open the raw data table using the previously saved file path.

I have used the code below to succesfully save the files and create the buttons but the file path always uses the last instance of the variable.

I suppose i was hoping when it created the button it would actually point to the correct file path/write the correct file path. Is this even possible or am i a few sandwichs short of a picnic!

Thanks for any advice.....

 

(temp, save("\\filepath\File_"||variable||"report.txt" ));

 

Data_button = V List Box( Button Box("OPEN RAW DATA  "||variable||"", open("\\filepath\File_"||variable||"report.txt" )));

data_button <<journal;

1 ACCEPTED SOLUTION

Accepted Solutions
Craige_Hales
Super User

Re: Create an open file button using a variable.

Here's one approach.  Expr( ... ) marks the value you need to cast in stone when the button is created.  Eval Expr( ... ) searches for Expr and evaluates it; the result in this example is the expression Button Box( "press", Show( "path\ right \ext" ) ). Eval( ... ) evaluates the Button Box expression.  All three are needed and work together.

x = "right";

New Window( "test", Eval( Eval Expr( Button Box( "press", (Show( Expr( "path\ " || x || " \ext" ) )) ) ) ) );

x = "wrong";

Print( "test the button" );

7488_buttonScript.PNG

Your example might look like this:

Data_button = V List Box(

  Eval(  Eval Expr( Button Box( "OPEN RAW DATA  " || variable || "",

  Open( Expr( "\filepath\File_" || variable || "report.txt" ) )  )  )  )

);

Open is not inside the expr; you don't want to do the open until the button is pressed.

Button Box doesn't evaluate its script until you press the button.  This is one way you can build the button script with the file name already cast in stone, not in a variable, so when the script does run the variable isn't needed.

Craige

View solution in original post

2 REPLIES 2
Craige_Hales
Super User

Re: Create an open file button using a variable.

Here's one approach.  Expr( ... ) marks the value you need to cast in stone when the button is created.  Eval Expr( ... ) searches for Expr and evaluates it; the result in this example is the expression Button Box( "press", Show( "path\ right \ext" ) ). Eval( ... ) evaluates the Button Box expression.  All three are needed and work together.

x = "right";

New Window( "test", Eval( Eval Expr( Button Box( "press", (Show( Expr( "path\ " || x || " \ext" ) )) ) ) ) );

x = "wrong";

Print( "test the button" );

7488_buttonScript.PNG

Your example might look like this:

Data_button = V List Box(

  Eval(  Eval Expr( Button Box( "OPEN RAW DATA  " || variable || "",

  Open( Expr( "\filepath\File_" || variable || "report.txt" ) )  )  )  )

);

Open is not inside the expr; you don't want to do the open until the button is pressed.

Button Box doesn't evaluate its script until you press the button.  This is one way you can build the button script with the file name already cast in stone, not in a variable, so when the script does run the variable isn't needed.

Craige
lenny
Level II

Re: Create an open file button using a variable.

You Sir are an absolute legend!!! Thank you so much for that it is exactly what i neeeded.