esmith Posted July 30, 2009 Share Posted July 30, 2009 I was hoping to be able to create a rule that would return a different result based on the particular input data file. Is it possible to test this information in a text/graphic rule? For example: return (FusionPro.Composition.inputFileName() == "sample.txt") ? *do this* : *DO THIS*; Link to comment Share on other sites More sharing options...
esmith Posted August 18, 2009 Author Share Posted August 18, 2009 Any answers from the men behind the curtain? The latest desire is to be able to set BodyPageUsage based on inputFileName, in this case used in an OnJobStart rule. Can FP retrieve the current input file's name through JS? Link to comment Share on other sites More sharing options...
chads Posted August 18, 2009 Share Posted August 18, 2009 I am hearing crickets. No help? Link to comment Share on other sites More sharing options...
tobarstep Posted August 18, 2009 Share Posted August 18, 2009 We have rules that use the InputFileName in non-callback procedures. The catch is that you can only test it by composing as the call to it does not return correctly in preview mode. Link to comment Share on other sites More sharing options...
chads Posted August 18, 2009 Share Posted August 18, 2009 Do you mind posting a sampling of the code? Link to comment Share on other sites More sharing options...
tobarstep Posted August 18, 2009 Share Posted August 18, 2009 Sure, not much to it really. Just assign it to a variable and then run whatever tests on it. var fileName = FusionPro.Composition.inputFileName; return (fileName.match(/testpattern/)) ? "good" : "bad"; // OR if you aren't using RegEx return (fileName.indexOf("testpattern")>-1) ? "good" : "bad"; In preview mode and in the code editor window you'll always get an error or sometimes even an erroneous result. You'll get correct results when composing though. Also note the inputFileName is a property of the Composition object, so the JS engine will complain if you put parentheses on the end of it. EDIT: looking at the JS String object, I see you can use the match() method even with string matching (non-RegEx). I never knew that as I've always used it with RegEx. Learned something new. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.