Jump to content

This topic is 4901 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies
Posted (edited)

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;

}

Edited by jpscharf
  • Newbies
Posted (edited)

To help determine the cause I did some additional testing:

Windows XP - no problems

Mac OS X 10.5 - no problems

Mac OS X 10.6 - no problems

Mac OS X 10.7 - crashes every time.

Tested FileDialog in the Groovy console (1.8.1). I had the script run the code four times consecutively and no crash. So the issue seems to be with either the the version of Groovy the plugin uses (1.7.6) or the plugin itself.


/*

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 openTitle = "Hello World!";

String defaultDirectory = "/Users/jpscharf/Desktop/";

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())

  selectedFile = openDialog.getDirectory() + openDialog.getFile();

  //return selectedFile;

} else {

  //return false;

}

openDialog.setDirectory(defaultDirectory);

openDialog.show();

if (openDialog.getFile() != null) {

  //selectedFile = fmpro.convertPathToFileMaker(openDialog.getDirectory() + openDialog.getFile())

  selectedFile = openDialog.getDirectory() + openDialog.getFile();

  //return selectedFile;

} else {

  //return false;

}

openDialog.setDirectory(defaultDirectory);

openDialog.show();

if (openDialog.getFile() != null) {

  //selectedFile = fmpro.convertPathToFileMaker(openDialog.getDirectory() + openDialog.getFile())

  selectedFile = openDialog.getDirectory() + openDialog.getFile();

  //return selectedFile;

} else {

  //return false;

}

openDialog.setDirectory(defaultDirectory);

openDialog.show();

if (openDialog.getFile() != null) {

  //selectedFile = fmpro.convertPathToFileMaker(openDialog.getDirectory() + openDialog.getFile())

  selectedFile = openDialog.getDirectory() + openDialog.getFile();

  //return selectedFile;

} else {

  //return false;

}

Edited by jpscharf
  • Newbies
Posted

The issue was with Default Folder, updating to version 4.4.4 resolves the issue.

This topic is 4901 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.