@Rohit Namjoshi thanks a lot!
Well, if the user cancels the browse dialog, this is equivalent to the statement
Import[$Canceled]
Can you think of a way so that my program doesn't return that error when the user cancels the dialog?
The only thing I can come up with now is a Switch
statement:
If the user completes the Import
, than get the values of content
. (Assuming that a text string is to be imported)
If, on the other way, the user cancels the dialog, than print the error "You canceled the dialog"
:
Button["Browse",
Switch[content = Import[SystemDialogInput["FileOpen"]],
Head[content] == String, content, Import[$Canceled],
"You canceled the dialog"], Method -> "Queued"]
But this rather produces two errors of the kind
Import: First argument $Canceled is not a valid file, directory, or URL specification.
and besides that the value assigned to content
is now $Failed
.
Any idea on how to elaborate this?
I am trying to build a sort of a (graphical) user interface inside Mathematica, and that's why this question arises.