Jump to content

Recommended Posts

Posted

I've got a test data file containing 7 records. When I compose the file I only get one record output. "All" is selected in the compose window. The following text is from the message log (Minus the header info):

Composing record #1, input record 1

Composing record #2, input record 2

Composing record #3, input record 3

Composing record #4, input record 4

Composing record #5, input record 5

Composing record #6, input record 6

Composing record #7, input record 7

Job ended 09:32:19 - 1540992739.

Total Job Time: 1s

 

I'm not getting any other errors.

 

fyi. This file uses JavaScript code in the OnRecordStart callback to set the Page outputs and some address fields that may or may not contain an address. On my machine this file also exhibits the Preview jpg not showing, but being correct on output.

 

Mac 10.13.6

FusionPro® VDP Creator 10.0.26

Acrobat Build: 19.8.20080.306727

:confused:

Posted

Sorry for getting this in the JavaScript thread.

 

Anyway...I know I didn't do this, but all the page usage was was set to "Unused" in the Manage page area...Or maybe I'm just going nuts?

 

Still have no images on the preview.

Posted
Nope, that's not it either. All that does is have all pages output. Not what I'm looking for either. Scott can I send you this personally? I'd have to strip out Customer data before I'd want to post to a public forum.
Posted

Here is everything I currently have in the OnRecordStart

**Note. I'm seeing some weird spaces in my code previewing on the web page that don't exist

 

//Look to the Javascript Globals settings for the declared variables.

 

function myReturn(a){

if(a !=""){

a = "\n" + a;

}

return a;

}

function myPh(a){

if(a !=""){

a = "\nP: " + a;

}

return a;

}

function myFax(a){

if(a !=""){

a = "\nF: " + a;

}

return a;

}

 

if (Field("Pharmacy1")){

pharms.push(Field("Pharmacy1"));

pharmAdd.push(Field("Street1") +myReturn(Field("Suite1")) +"\n"+ Field("City1") +", "+Field("State1") +" "+Field("Zip1") + myPh(Field("Phone1")) + myFax(Field("Fax1")));

}

 

if (Field("Pharmacy2")){

pharms.push(Field("Pharmacy2"));

pharmAdd.push(Field("Street2") +myReturn(Field("Suite2")) +"\n"+ Field("City2") +", "+Field("State2") +" "+Field("Zip2") + myPh(Field("Phone2")) + myFax(Field("Fax2")));

}

 

if (Field("Pharmacy3")){

pharms.push(Field("Pharmacy3"));

pharmAdd.push(Field("Street3") +myReturn(Field("Suite3")) +"\n"+ Field("City3") +", "+Field("State3") +" "+Field("Zip3") + myPh(Field("Phone3")) + myFax(Field("Fax3")));

}

//Allows the skipping of data rows that don't contain a Pharmacy and shifts the data forward. eg. All data in group 3 goes to 2 if 2 is empty.

if (pharms[0]){

address1=pharmAdd[0];

pharmacy1 = pharms[0];

}

if (pharms[1]){

address2=pharmAdd[1];

pharmacy2 = pharms[1];

}

if (pharms[2]){

address3=pharmAdd[2];

pharmacy3 = pharms[2];

}

 

if (pharms.lenght == 1){

FusionPro.Composition.SetBodyPageUsage("One",true);

FusionPro.Composition.SetBodyPageUsage("Two",true);

FusionPro.Composition.SetBodyPageUsage("Three",false);

FusionPro.Composition.SetBodyPageUsage("Four",false);

FusionPro.Composition.SetBodyPageUsage("Five",false);

FusionPro.Composition.SetBodyPageUsage("Six",false);

}

 

if (pharms.lenght == 2){

FusionPro.Composition.SetBodyPageUsage("One",false);

FusionPro.Composition.SetBodyPageUsage("Two",false);

FusionPro.Composition.SetBodyPageUsage("Three",true);

FusionPro.Composition.SetBodyPageUsage("Four",true);

FusionPro.Composition.SetBodyPageUsage("Five",false);

FusionPro.Composition.SetBodyPageUsage("Six",false);

}

 

if (pharms.lenght == 3){

FusionPro.Composition.SetBodyPageUsage("One",false);

FusionPro.Composition.SetBodyPageUsage("Two",false);

FusionPro.Composition.SetBodyPageUsage("Three",false);

FusionPro.Composition.SetBodyPageUsage("Four",false);

FusionPro.Composition.SetBodyPageUsage("Five",true);

FusionPro.Composition.SetBodyPageUsage("Six",true);

}

/*switch(pharms.length){

 

case 1: FusionPro.Composition.SetBodyPageUsage("One",true);

FusionPro.Composition.SetBodyPageUsage("Two",true);

break;

case 2: FusionPro.Composition.SetBodyPageUsage("Three",true);

FusionPro.Composition.SetBodyPageUsage("Four",true);

break;

case 3: FusionPro.Composition.SetBodyPageUsage("Five",true);

FusionPro.Composition.SetBodyPageUsage("Six",true);

}*/

Posted

Thanks, posting the code is helpful. It's still hard to completely analyze this by looking through the keyhole of just the JavaScript rule, without having the rest of the job.

 

That said, I think the root of your problem is this:

if (pharms.lenght == 1){

You've misspelled the Array "length" property. Changing all those to this will probably help:

if (pharms.length == 1){

Also, your code with all those FusionPro.Composition.SetBodyPageUsage calls is way more verbose than it needs to be. Your commented-out switch statement is much better. But if you set all those pages to be Unused in the Page Usage dialog (and you don't even need to name them), then I think you can replace it all with this:

var frontPage = ((pharms.length - 1) * 2) + 1;
FusionPro.Composition.SetBodyPageUsage(frontPage, true );
FusionPro.Composition.SetBodyPageUsage(++frontPage, true);

And anyone who's been on this forum for a while probably won't be surprised when I tell you that the other code, with the three blocks for Pharmacy1, Pharmacy2, and Pharmacy3, can also be reduced with a "for" loop, like so:

for (var i = 1; i <= 3; i++)
{
   if (Field("Pharmacy" + i)){
       pharms.push(Field("Pharmacy" + i));
       pharmAdd.push(Field("Street" + i) +myReturn(Field("Suite" + i)) +"\n"+ Field("City" + i) +", "+Field("State" + i) +" "+Field("Zip" + i) + myPh(Field("Phone" + i)) + myFax(Field("Fax" + i)));
   }
}

Other code reductions are possible as well.

Posted

I took out the page names and changed my code per your suggestions to

//Look to the Javascript Globals settings for the declared variables. var pharmAdd=[], pharms = [], address1, address2, address3, pharmacy1, pharmacy2, pharmacy3;

 

function myReturn(a){

if(a !=""){

a = "\n" + a;

}

return a;

}

function myPh(a){

if(a !=""){

a = "\nP: " + a;

}

return a;

}

function myFax(a){

if(a !=""){

a = "\nF: " + a;

}

return a;

}

 

 

//Assign Pharmacy Names to pharms array and corresponding address to pharmAdd array.

//Allows the skipping of data rows that don't contain a Pharmacy and shifts the data forward. eg. All data in group 3 goes to array 2 if group 2 is empty.

for (var i = 1; i <= 3; i++)

{

if (Field("Pharmacy" + i)){

pharms.push(Field("Pharmacy" + i));

pharmAdd.push(Field("Street" + i) +myReturn(Field("Suite" + i)) +"\n"+ Field("City" + i) +", "+Field("State" + i) +" "+Field("Zip" + i) + myPh(Field("Phone" + i)) + myFax(Field("Fax" + i)));

}

}

 

if (pharms[0]){

address1=pharmAdd[0];

pharmacy1 = pharms[0];

}

if (pharms[1]){

address2=pharmAdd[1];

pharmacy2 = pharms[1];

}

if (pharms[2]){

address3=pharmAdd[2];

pharmacy3 = pharms[2];

}

 

var frontPage = ((pharms.length - 1) * 2) + 1;

FusionPro.Composition.SetBodyPageUsage(frontPage, true );

FusionPro.Composition.SetBodyPageUsage(++frontPage, true);

 

However when I compose it I get the following which again has me baffled??

Composing record #1, input record 1

uncaught exception: Error: In SetBodyPageUsage(), invalid page number 9

Composing record #2, input record 2

uncaught exception: Error: In SetBodyPageUsage(), invalid page number 11

Composing record #3, input record 3

uncaught exception: Error: In SetBodyPageUsage(), invalid page number 15

Composing record #4, input record 4

uncaught exception: Error: In SetBodyPageUsage(), invalid page number 19

Composing record #5, input record 5

uncaught exception: Error: In SetBodyPageUsage(), invalid page number 25

Composing record #6, input record 6

uncaught exception: Error: In SetBodyPageUsage(), invalid page number 29

Composing record #7, input record 7

uncaught exception: Error: In SetBodyPageUsage(), invalid page number 31

Composing record #8, input record 8

Job ended 15:40:16 - 1541101216.

Total Job Time:

 

...and good Lord I looked and that code for two days and didn't see I miss-spelled length...AAAAhHHHHHHHH!!!!!

Posted (edited)
However when I compose it I get the following which again has me baffled??

So again, without the job files, I kind of have to guess as to the larger context of what's going on. But the pharms array is global, and this code is in OnRecordStart, right? So I think you need to clear your arrays for each record, like so, at the start of the rule:

pharms = [];
pharmAdd = [];

...and good Lord I looked and that code for two days and didn't see I miss-spelled length...AAAAhHHHHHHHH!!!!!

Sometimes when you're stuck like this, it's good to add some debugging code, just to "sanity check" your logic. Adding a line such as:

return pharms.lenght;

would probably have led you to find the mistake. And even adding

return pharms.length;

would have helped to figure out why you were getting those invalid page numbers, because your global array wasn't being cleared between records. I often leave little debugging lines like that in the rule, commented out.

Edited by Dan Korn
added note about debugging
Posted
Dan, you were spot on with clearing the array. Thank you so much this is now working fantastic!!!

No problem. At the risk of breaking things again, I'll suggest an alternate way of doing this that doesn't require global variables, or any other rules to access them. Instead of declaring those in the JavaScript Globals, and then making other rules to return them, you can do everything in OnRecordStart, if you add a couple of calls to FusionPro.Composition.AddVariable, where the first parameter in each call is the name of the rule that you no longer need, and the second parameter is what that rule returned, similar to this post:

http://forums.pti.com/showpost.php?p=21561&postcount=2

Posted

Setting up without a rule first question.

After removing my rule I have no option to add this new variable to a FusionPro Text frame via the variable dropdown. It also can't be typed using Chevrons in the text edit window...However, if I type the new variable in BBedit with the Chevrons and then copy and past I can add the variable to the text edit window via copy and paste. Is this the expected behavior or should I go thru the trouble of making a rule so I can select it and then when completed delete the rule?

Posted
Setting up without a rule first question.

After removing my rule I have no option to add this new variable to a FusionPro Text frame via the variable dropdown. It also can't be typed using Chevrons in the text edit window...However, if I type the new variable in BBedit with the Chevrons and then copy and past I can add the variable to the text edit window via copy and paste. Is this the expected behavior or should I go thru the trouble of making a rule so I can select it and then when completed delete the rule?

The Variable control on the Text Editor isn't a simple drop-down; it's a "combo" drop-down and text box. So just type the name in there and click Insert.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...