• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to check if cancel has been pressed in a save dialog window

Participant ,
Dec 13, 2017 Dec 13, 2017

Copy link to clipboard

Copied

Hi everyone!

I have a problem that I don't know how to solve. My script gives you the possibility to save a file manually using a Save Dialog window, but I don't know how to check if save or cancel have been pressed so the script stops. This is the code

                var dskTop = (outputPath + "/assets/assets_data/");  

                var dskPth = String(dskTop);

                var newSpot = new File(dskPth+"/exporting_name");

                myFilePath = newSpot.saveDlg('Select Destination Folder', '*.js');

               

                //HOW COULD I CHECK IF CANCEL HAS BEEN PRESSED?

                myFile = new File(myFilePath);

               

                // SO THIS FUNTON DOESNT START

                exportInfoFunction();

               

                //we check if the has been any error in the "exportInfoFunction" function

                if (theresAnError == 0){

                    if (myFile.exists){

                        alert("The file has been successfully exported");

                    }

                }

Thanks!

Views

326

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Participant , Dec 18, 2017 Dec 18, 2017

Stupid me.... Just checking if myFilePath == null does it. If you press cancel you don't get this data so enough for me to stop the script and don't execute the function

Votes

Translate

Translate
LEGEND ,
Dec 13, 2017 Dec 13, 2017

Copy link to clipboard

Copied

You can only check such stuff by creating your own dialogs. The system dialogs are modal and don't return any info beyond having been opened or closed. The scripts have no idea what a system file dialog actually does. it could contain a hundred buttons and you wouldn't know which ones were pressed.

Mylenium

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 14, 2017 Dec 14, 2017

Copy link to clipboard

Copied

Thanks for the reply!!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 18, 2017 Dec 18, 2017

Copy link to clipboard

Copied

LATEST

Stupid me.... Just checking if myFilePath == null does it. If you press cancel you don't get this data so enough for me to stop the script and don't execute the function

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines