I have two function (GUI) in ScriptMaster Advanced, each show their own dialog (Save and Open), but if they are run in the same script (or subscript) they crash FileMaker, it does not matter whether they are registered with ScriptMaster or are from custom plugin. Also, if the same function is called in the same script (or subscript) FileMaker crashes. Here is the code for the two functions:
/*
Purpose: Asks a user to select a file to open.
Returns: File Path
Name: HIDRAOpenFileDialog ( saveTitle ; defaultDirectory )
Parameters: ( openTitle ) text
( defaultDirectory ) filepath
Dependencies: NONE
2011-09-01 JPS, Created.
NOTES:
NONE
*/
import java.awt.*;
import javax.swing.JOptionPane;
String title = openTitle;
FileDialog openDialog = new FileDialog(JOptionPane.getRootFrame(),title, FileDialog.LOAD);
openDialog.setDirectory(defaultDirectory);
openDialog.show();
if (openDialog.getFile() != null) {
selectedFile = fmpro.convertPathToFileMaker(openDialog.getDirectory() + openDialog.getFile())
openDialog = null;
return selectedFile;
} else {
openDialog = null;
return false;
}
/*
Purpose: Asks a user for a save location and filename.
Returns: File Path
Name: HIDRASaveFileDialog ( saveTitle ; defaultDirectory ; defaultFileName )
Parameters: ( saveTitle ) text
( defaultDirectory ) filepath
( defaultFileName ) text
Dependencies: NONE
2011-09-01 JPS, Created.
NOTES:
NONE
*/
import java.awt.*;
import javax.swing.JOptionPane;
String title = saveTitle;
FileDialog saveDialog = new FileDialog(JOptionPane.getRootFrame(),title, FileDialog.SAVE);
saveDialog.setDirectory(defaultDirectory);
saveDialog.setFile(defaultFileName);
saveDialog.show();
if (saveDialog.getFile() != null) {
selectedFile = fmpro.convertPathToFileMaker(saveDialog.getDirectory() + saveDialog.getFile())
saveDialog = null;
return selectedFile;
} else {
saveDialog = null;
return false;
}