View Single Post
  #1  
Old 08-29-2015, 03:50 PM
cjmccormack cjmccormack is offline
Registered User
 
Join Date: Aug 2015
Posts: 3
Question File Open Dialog - how to determine if user hits 'Cancel'

Hello,

I'm writing a script for running several show commands pre- and post- switch refresh.

The script does the following:
- Parses the last line of a session to get both the prompt and the hostname, the hostname derived from the prompt
- Using the hostname and date parameters, sets the crt.Session.LogFileName to a custom string that auto-populates the filename in the FileOpenDialog
- Opens a crt.Dialog.FileOpenDialog so the user can select the path and change the filename if needed.

After this is done, logging is enabled, the commands are run, logging is disabled again then the script terminates.

My current issue is I'm not sure how to handle the case where the user selects 'Cancel' in the FileOpenDialog box. I would like the script to terminate at that point, but because I have a filename auto-populated, the return value would only be an empty string if the user actually removed the entire filename. It is far more convenient to have the filename auto-populated so removing that is pretty much out of the question.

Are there any methods of the Dialog class that aren't well documented that I could use? Is there an easy way to handle this I may have just missed?

Many thanks!
Reply With Quote