A cancelled choosefiledialog process opens a new file


#1

If I hit the Cancel button in the dialog box generated by the choosefiledialog statement, a new, unwanted empty file opens and I have to close it. Is this supposed to happen?


#2

It is not supposed to happen, nor does it. I just tested to make sure.

I’m guessing that you have some code after the choosefiledialog, and that you are not testing to check whether the Cancel button has been pressed, so that additional code is running when you don’t want it to. The documentation for this statement says:

Note: The program can determine whether the user pressed the Ok or Cancel button by checking the info(“dialogtrigger”) function. In addition, if the Cancel button is pressed the path parameter will be set to “” (empty).)

So you must check this yourself (this is because otherwise Panorama would not know what you want to do when Cancel is pressed – you might want to just stop, or display an error message, or load a default file, the options are endless).

Here is a typical example that just stops if the Cancel button is pressed.

local fileChoice
choosefileDialog fileChoice
if filechoice="" return endif
...
... do more stuff
...

Or, you could do this:

local fileChoice
choosefileDialog fileChoice
if info("dialogtrigger")="Cancel" return endif
...
... do more stuff
...

Although this is documented, I have to admit that it would be nice if the documentation included an example illustrating how this is done.


#3

I can take a hint - I’ve just done that for you.


#4

It wasn’t a hint, but thanks.

For those of you that aren’t aware, anyone can submit changes to a Panorama Help documentation page. Michael in particular has submitted hundreds of corrections and clarifications. David Thompson and Gary Yonaites have also been big contributors, and one or two dozen of you have made at least one submission. Thank you to all of you.

If anyone new is interested in doing this, see "Advanced: Submitting Corrections” on this help page.


#5

I realise that but it was just so easy to cut and paster your response.