Subscribe Bookmark RSS Feed

Create an open file button using a variable.

lenny

Community Trekker

Joined:

Oct 24, 2014

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
Solution

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
2 REPLIES
Solution

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

Community Trekker

Joined:

Oct 24, 2014

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