Code: Select all
{
const dia = {
open(dialog) {
const path = app.browseForDoc();
Promise.resolve(path)
.then( p => {
// put the file opening into async
return app.openDoc({
cPath: p.cPath,
cFS: p.cFS,
});
})
.catch( e => dialog.load({'fPth': e}));
// do something with the dialog before the async
dialog.load({'fPth': path.cPath});
},
description: {name: "Open file", elements: [
{ type: 'static_text', name: "Select a file to open", width: 300},
{ type: 'button', name: 'Browse…', item_id: 'open'},
{ type: 'static_text', name: "", item_id: 'fPth', alignment: 'align_fill'},
]}
};
app.execDialog(dia);
}Code: Select all
{
const dia = {
open(dialog) {
const path = app.browseForDoc();
const doc = app.openDoc({
cPath: path.cPath,
cFS: path.cFS,
});
Promise.resolve(doc)
.then( p => {
p.dirty = true;
// "do you want to save?"
return p.closeDoc(false)
})
.catch( e => dialog.load({'fPth': e}));
// do something with the dialog before the async
dialog.load({'fPth': path.cPath});
},
description: {name: "Open file", elements: [
{ type: 'static_text', name: "Select a file to open", width: 300},
{ type: 'button', name: 'Browse…', item_id: 'open'},
{ type: 'static_text', name: "", item_id: 'fPth', alignment: 'align_fill'},
]}
};
app.execDialog(dia);
}