PaulSamuelson Posted June 22, 2016 Share Posted June 22, 2016 The following is the "Copy File" function from the ScriptMaster FMP12 file. It works as it should. I need to register it as a function, and am having problems getting the return state back (because I don't know enough Java): *************************************************** InputStream input = new BufferedInputStream(new FileInputStream(src)); OutputStream out = new BufferedOutputStream(new FileOutputStream(dest)); try { out << input; } finally { if (out != null) out.close(); if (input != null) input.close(); } return true; *************************************************** This is what I was trying to use as a formula in a Set Variable step of an initialization script. *************************************************** RegisterGroovy( "CopyFile( src ; dest )" ; " InputStream input = new BufferedInputStream(new FileInputStream(src)); OutputStream out = new BufferedOutputStream(new FileOutputStream(dest)); try { out << input; } finally { if (out != null) out.close(); if (input != null) input.close(); } return true;") *************************************************** Please help me get tot he correct formatting of the RegisterGroovy function. Thanks, Paul Samuelson Link to comment Share on other sites More sharing options...
ryan360Works Posted June 23, 2016 Share Posted June 23, 2016 Paul, If you register the function in the Scriptmaster file by clicking on "Register Function" at the bottom of the module, it will take you to another layout that tells you how to incorporate the module. The third choice gives you an option to copy to your clipboard. This will be the correct syntax to paste into a set variable script step. Have you done this? This is what I get when I copy it to the clipboard RegisterGroovy( "CopyFile( src ; dest )" ; "InputStream input = new BufferedInputStream(new FileInputStream(src));¶ OutputStream out = new BufferedOutputStream(new FileOutputStream(dest));¶ try {¶ out << input;¶ } finally {¶ if (out != null) out.close();¶ if (input != null) input.close();¶ }¶ ¶ return true;"; "isGui=false" ) Link to comment Share on other sites More sharing options...
PaulSamuelson Posted June 23, 2016 Author Share Posted June 23, 2016 Ryan, I did not know that. That helps a lot! Thank you, Paul Link to comment Share on other sites More sharing options...
Recommended Posts
This topic is 2835 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 accountSign in
Already have an account? Sign in here.
Sign In Now