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 Module, DynamicModule, Return or something else?

Buttonneeds the optionMethod->"Queued"(see wolfram.com/xid/0mrh4y-k6ay1g) – Sjoerd C. de Vries Oct 25 '12 at 8:53