Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

Posted (edited)

Hello

Filemaker Version: Filemaker Pro Adv 11 v.02

Something strange is going on, and my skills do not alow me to understand whats going on.

Replace the "Zip File" function in the Scriptmaster.fp7 file with the function below.

Then add a second container field into the Demo table. do "Insert File" on this container. Choose the any :P file.

This new container is your "src" parameter. Run the function, and it works perfectly. The function save the contants of the container as a temporary file, and returns its path.

Problem:

When I register this function at startup with my own filemaker file, then it can ONLY be used when I export(once per filemaker session)some container field in the database first. The database must be the one where I want to use the function. If i do not export some field, then the function will return an error.

As soon as I export something, the function works, for the rest of the session. You could sya that "export content" is a trigger that allows my function to work.

Well this sucks :

InputStream srcIn;

String srcName;



if (src == null) throw new IllegalArgumentException("no src file was specified");

if (src.indexOf("::") != -1) {

	// this is a field name in filemaker, not a path

	srcIn = fmpro.getContainerStream(src);

	srcName = fmpro.getContainerFileName(src);

} else {

	File f = new File(src);

	if (!f.exists()) throw new FileNotFoundException(f.getAbsolutePath());

	if (!f.isFile() || !f.canRead()) throw new IOException("File " + f + " is not a normal file, or cannot be read");

	srcIn = new FileInputStream(f);

	srcName = f.getName();



}







try {

	File d ;

	if (destination == null || destination.length() == 0) {

	//	d = File.createTempFile("scriptmaster_zip_", ".zip");

		d = new File(System.getProperty("java.io.tmpdir"));		



	} else {

		d = new File(destination);

	}

	if (d.isDirectory()) d = new File(d, srcName );

	if (d.exists() && !d.delete()) throw new IOException("Could not delete " + d.getAbsolutePath());



	fos = new FileOutputStream( d.getPath() ); 





	InputStream input = new BufferedInputStream(srcIn);

	OutputStream out = new BufferedOutputStream(fos);

	out << input;





	return d.getPath();	

} finally {

	if (out != null) out.close();

	if (input != null) input.close();

}

Edited by Guest

This topic is 5133 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.