dmp Posted September 19, 2017 Posted September 19, 2017 Hi there, I'm getting weird results and I'm not sure where my code is wrong. I have 4 pages all set to unused. Local records are page 1 & 2 Out of state are 3 & 4 so I'm using this OnRecordStart rule but I'll get something like record 1 = pg 1,3,4. if (Field("List")=="Local") { FusionPro.Composition.SetBodyPageUsage("1", true) FusionPro.Composition.SetBodyPageUsage("2", true) FusionPro.Composition.SetBodyPageUsage("3", false) FusionPro.Composition.SetBodyPageUsage("4", false) } if (Field("List")=="Out of State") FusionPro.Composition.SetBodyPageUsage("1", false) FusionPro.Composition.SetBodyPageUsage("2", false) FusionPro.Composition.SetBodyPageUsage("3", true) FusionPro.Composition.SetBodyPageUsage("4", true) }I tried to look at the code Dan wrote for page ranges, but I can't wrap my head around the var i <= 6 i++ stuff. o.O Anyone know what I'm doing wrong here? Cheers, Mike Quote
step Posted September 19, 2017 Posted September 19, 2017 Are your pages named 1, 2, 3, and 4? If not you may need to make the page numbers integers instead of strings: if (Field("List")=="Local") { FusionPro.Composition.SetBodyPageUsage(1, true) FusionPro.Composition.SetBodyPageUsage(2, true) FusionPro.Composition.SetBodyPageUsage(3, false) FusionPro.Composition.SetBodyPageUsage(4, false) } if (Field("List")=="Out of State") FusionPro.Composition.SetBodyPageUsage(1, false) FusionPro.Composition.SetBodyPageUsage(2, false) FusionPro.Composition.SetBodyPageUsage(3, true) FusionPro.Composition.SetBodyPageUsage(4, true) } Or: var page = Field("List") == "Local" ? 1 : 3; FusionPro.Composition.SetBodyPageUsage(page, true); FusionPro.Composition.SetBodyPageUsage(page + 1, true); Quote
dmp Posted September 19, 2017 Author Posted September 19, 2017 Yes the pages are just named 1 2 3 and 4 respectively. ok so putting the "" changes the meaning! I see. thanks Step What does this mean after the local: ? 1 : 3; Quote
step Posted September 19, 2017 Posted September 19, 2017 It's a ternary operator. It's a shorthand way of writing this: if (Field("List") == "Local") { var page = 1; } else { var page = 3; } Quote
dmp Posted September 19, 2017 Author Posted September 19, 2017 OK, and then the page and page + 1 just grabs the next page after 1 and 3 respectively? That code worked great. I didn't have success just removing the "" 's though. Thanks Step for explaining it too! Quote
Recommended Posts
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.