cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
ARETI052
Level III

Not a Name Error when after selecting file path for saving PNG

Hi, I am trying to modify my code so that the user can selected which file path to save the result PNG files as well as naming the PNG files. The code is a subscript that will be called by the main script. My problem is that after I select the path and name the PNG file, I get a "Not a Name" error, the PNG file will be saved to the path I selected but the naming won't go through. How can I fix this?

Thanks!

MyGraph = Function({yCol},
    {default local},
    vars = Eval Expr(Variables(
        X(:Test Stage),
        Group X(:Lot)
    ));

    pts = Expr(Box Plot(X));

    For(j = 1, j <= Min(8, N Items(yCol)), j++,
        Insert Into(vars, Eval Expr(Y(Expr(yCol[j]), Position(1))));
    );

    gb = Expr(
        Graph Builder(
            Size(1255, 981),
            Show Control Panel(0),
            Elements(Box Plot(X, Y(1), Y(2), Y(3), Y(4), Y(5), Y(6), Y(7), Y(8))),
            Local Data Filter(
                Add Filter(
                    columns(:Test Stage, :Sublot, :Temperature, :Soft Bin, :Serial Id),
                    Display(:Test Stage, N Items(4)),
                    Display(:Soft Bin, N Items(15))
                )
            )
        )
    );
    Insert Into(gb, Name Expr(vars));

    // Prompt the user to select a directory to save the PNG
    dir_path = Pick Directory("Select Directory to Save PNG");

    // Check if the user selected a directory
    If(Is Empty(dir_path) == 0,
        // Ask for the file name using New Window
        nw = New Window("Save File", <<Modal,
            VListBox(
                Text Box("Enter filename:"),
                file_name_box = Text Edit Box("box_FT1vsFT2")
            ),
            Button Box("OK", Dialog(0))
        );

        // Extract the file name from the text edit box
        file_name = Char(Eval(file_name_box));  // Convert to string explicitly

        // Construct the full path
        png_path = dir_path || "/" || file_name || ".png";

        // Save the picture
        gb << Save Picture(png_path, "png");
    ,
        Caption("Save operation was canceled.")
    );
);

dt = Current Data Table();

New Window("My report",
    VListBox(
        MyGraph(::yColName)
    )
);
1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Not a Name Error when after selecting file path for saving PNG

Have you verified that file_name contains what you think it does? You most likely want to either use << return results or get the value from text edit box using << get text when OK is pressed.

-Jarmo

View solution in original post

1 REPLY 1
jthi
Super User

Re: Not a Name Error when after selecting file path for saving PNG

Have you verified that file_name contains what you think it does? You most likely want to either use << return results or get the value from text edit box using << get text when OK is pressed.

-Jarmo