I need to create a simple user interface to choose one file in the notebook directory, import it and execute some functions on the imported data. For the first version I created this code:
Button["get File Path", fileData = Import@SystemDialogInput["FileOpen", NotebookDirectory]; ]; function[fileData]
Now I want it to be a little bit more error proof, so if you cancel your selection, you don't get an error, and the rest of your code is not executed.
Button["get File Path", fileData=Quiet@Check[Import@SystemDialogInput["FileOpen",NotebookDirectory],$Canceled] ] If[fileData!=$Canceled,function[fileData]]
I don't feel that it is the best practice for this kind of situation.
Some clue to make the code more intelligent? Maybe with
Return or something else?