Go Back   Printable User Community > Software-Related Talk > The JavaScript Library

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old August 19th, 2009, 08:56 AM
anthony.bice anthony.bice is offline
Junior Community Member
 
Join Date: Jun 2009
Location: Houston Texas
Posts: 15
Default On Record Start Page Usage-repeating a set of conditions

Hello All,
I've successfully placed a set of 6 conditions as an if/else statement within an On Record Start rule, which returns one of 6 different body pages based on pricing variable entries. I'm calling that a "set" of conditions.

I now need to add 2 additional layouts options [Unit of Sale] (which will contain 6 pages each, that change with the pricing entries); and, a pull down menu (i.e. 1 For, 2 For, 3 For) with three choices that will call the appropriate set of (6) conditions.

I've attempted to add the "Unit of Sale" conditions within all my statements with "Logical Ands", duplicate the set of 6 for the other 2 layouts, and edit the body pages that are being called.

Can anyone offer any help with this attempt or direction? Thanks. :-)

Here's my stab at containing this in one On Record Start Rule (it validates but doesn't return any preview so far) :


if (Field("UnitOfSale") == "1 For" && Field("DollarAmount") >= 20)
{
FusionPro.Composition.SetBodyPageUsage("TwentyPlus PricingLayout", true);
}

else if (Field("UnitOfSale") == "1 For" && Field("DollarAmount") == 11)
{
FusionPro.Composition.SetBodyPageUsage("DollarAmou ntEleven", true);
}

else if (Field("UnitOfSale") == "1 For" && Field("DollarAmount") >= 10)
{
FusionPro.Composition.SetBodyPageUsage("DoubleDigi tPricingLayout", true);
}

else if (Field("UnitOfSale") == "1 For" && Field("DollarAmount") == 1)
{
FusionPro.Composition.SetBodyPageUsage("DollarAmou ntOne", true);
}

else if (Field("UnitOfSale") == "1 For" && Field("DollarAmount") == "")
{
FusionPro.Composition.SetBodyPageUsage("LessThanOn eDollar", true);
}

else (Field("UnitOfSale") == "1 For")
{
FusionPro.Composition.SetBodyPageUsage("SingleDigi tPricingLayout", true);
}


if (Field("UnitOfSale") == "2 For" && Field("DollarAmount") >= 20)
{
FusionPro.Composition.SetBodyPageUsage("2ForTwenty PlusPricing", true);
}

else if (Field("UnitOfSale") == "2 For" && Field("DollarAmount") == 11)
{
FusionPro.Composition.SetBodyPageUsage("2ForDollar AmountEleven", true);
}

else if (Field("UnitOfSale") == "2 For" && Field("DollarAmount") >= 10)
{
FusionPro.Composition.SetBodyPageUsage("2ForDouble DigitPricing", true);
}

else if (Field("UnitOfSale") == "2 For" && Field("DollarAmount") == 1)
{
FusionPro.Composition.SetBodyPageUsage("2ForDollar AmountOne", true);
}

else if (Field("UnitOfSale") == "2 For" && Field("DollarAmount") == "")
{
FusionPro.Composition.SetBodyPageUsage("2ForLessTh anOneDollar", true);
}

else (Field("UnitOfSale") == "2 For")
{
FusionPro.Composition.SetBodyPageUsage("2ForSingle DigitPricing", true);
}

if (Field("UnitOfSale") == "3 For" && Field("DollarAmount") >= 20)
{
FusionPro.Composition.SetBodyPageUsage("3ForTwenty PlusPricing", true);
}

else if (Field("UnitOfSale") == "3 For" && Field("DollarAmount") == 11)
{
FusionPro.Composition.SetBodyPageUsage("3ForDollar AmountEleven", true);
}

else if (Field("UnitOfSale") == "3 For" && Field("DollarAmount") >= 10)
{
FusionPro.Composition.SetBodyPageUsage("3ForDouble DigitPricing", true);
}

else if (Field("UnitOfSale") == "3 For" && Field("DollarAmount") == 1)
{
FusionPro.Composition.SetBodyPageUsage("3ForDollar AmountOne", true);
}

else if (Field("UnitOfSale") == "3 For" && Field("DollarAmount") == "")
{
FusionPro.Composition.SetBodyPageUsage("3ForLessTh anOneDollar", true);
}

else (Field("UnitOfSale") == "3 For")
{
FusionPro.Composition.SetBodyPageUsage("3ForSingle DigitPricing", true);
}
__________________
Anthony Bice
Pointsmith LLC - Houston, TX
FP 6.2P1a, MAC OSX 10.5.8, Acrobat 9.3.2
Reply With Quote
  #2  
Old August 19th, 2009, 09:38 AM
esmith's Avatar
esmith esmith is offline
Senior Contributor
 
Join Date: Oct 2008
Location: Charlotte, NC
Posts: 428
Default Re: On Record Start Page Usage-repeating a set of conditions

Quote:
Originally Posted by anthony.bice View Post
Code:
if (Field("UnitOfSale") == "1 For" && Field("DollarAmount") >= 20)
{
    FusionPro.Composition.SetBodyPageUsage("TwentyPlusPricingLayout", true);
}

else if (Field("UnitOfSale") == "1 For" && Field("DollarAmount") == 11)
{
    FusionPro.Composition.SetBodyPageUsage("DollarAmountEleven", true);
}

else if (Field("UnitOfSale") == "1 For" && Field("DollarAmount") >= 10)
{
	FusionPro.Composition.SetBodyPageUsage("DoubleDigitPricingLayout", true);
}
The first and third tests above contradict each other although I suppose due to the order they are written, JS might allow it so that all numbers greater than 10, but less than 20 skip the first test and then qualify on the 3rd.
Quote:
Originally Posted by anthony.bice View Post
Code:
else (Field("UnitOfSale") == "1 For")
{
FusionPro.Composition.SetBodyPageUsage("SingleDigi tPricingLayout", true);
}
There shouldn't be a test condition for the final ELSE as this is the catch all for a scenario that is not covered by any preceding IF or ELSE IF.

I think in this situation it would be better to use nested IFs like this:
Code:
if (Field("UnitOfSale") == "1 For") {
	if (Field("DollarAmount") >= 20) {
		FusionPro.Composition.SetBodyPageUsage("TwentyPlusPricingLayout", true);
		}
	else if (Field("DollarAmount") == 11) {
		FusionPro.Composition.SetBodyPageUsage("DollarAmountEleven", true);
		}
	else if (Field("DollarAmount") >= 10) {
		FusionPro.Composition.SetBodyPageUsage("DoubleDigitPricingLayout", true);
		}
	else if (Field("DollarAmount") == 1) {
		FusionPro.Composition.SetBodyPageUsage("DollarAmountOne", true);
		}
	else if (Field("DollarAmount") == "") {
		FusionPro.Composition.SetBodyPageUsage("LessThanOneDollar", true);
		}
	else {
		FusionPro.Composition.SetBodyPageUsage("SingleDigitPricingLayout", true);
		}
	}
else if (Field("UnitOfSale") == "2 For") {
	if (Field("DollarAmount") >= 20) {
		FusionPro.Composition.SetBodyPageUsage("2ForTwentyPlusPricing", true);
		}
	else if (Field("DollarAmount") == 11) {
		FusionPro.Composition.SetBodyPageUsage("2ForDollarAmountEleven", true);
		}
	else if (Field("DollarAmount") >= 10) {
		FusionPro.Composition.SetBodyPageUsage("2ForDoubleDigitPricing", true);
		}
	else if (Field("DollarAmount") == 1) {
		FusionPro.Composition.SetBodyPageUsage("2ForDollarAmountOne", true);
		}
	else if (Field("DollarAmount") == "") {
		FusionPro.Composition.SetBodyPageUsage("2ForLessThanOneDollar", true);
		}
	else {
		FusionPro.Composition.SetBodyPageUsage("2ForSingleDigitPricing", true);
		}
else if (Field("UnitOfSale") == "3 For") {
 	if (Field("DollarAmount") >= 20) {
		FusionPro.Composition.SetBodyPageUsage("3ForTwentyPlusPricing", true);
		}
	else if (Field("DollarAmount") == 11) {
		FusionPro.Composition.SetBodyPageUsage("3ForDollarAmountEleven", true);
		}
	else if (Field("DollarAmount") >= 10) {
		FusionPro.Composition.SetBodyPageUsage("3ForDoubleDigitPricing", true);
		}
	else if (Field("DollarAmount") == 1) {
		FusionPro.Composition.SetBodyPageUsage("3ForDollarAmountOne", true);
		}
	else if (Field("DollarAmount") == "") {
		FusionPro.Composition.SetBodyPageUsage("3ForLessThanOneDollar", true);
		}
	else {
		FusionPro.Composition.SetBodyPageUsage("3ForSingleDigitPricing", true);
		}
	}
__________________
Eric Smith
Prepress Guru
Classic Graphics
FP 7.0P1d, MAC OSX 10.6.4, Acrobat 9.3.3
Reply With Quote
  #3  
Old August 19th, 2009, 10:13 AM
anthony.bice anthony.bice is offline
Junior Community Member
 
Join Date: Jun 2009
Location: Houston Texas
Posts: 15
Default Re: On Record Start Page Usage-repeating a set of conditions

Thank You Mr. Smith, I'll put this approach to use at once and let you know. Thanks very much for the quick reply, you rock.
Anthony Bice
__________________
Anthony Bice
Pointsmith LLC - Houston, TX
FP 6.2P1a, MAC OSX 10.5.8, Acrobat 9.3.2
Reply With Quote
  #4  
Old August 19th, 2009, 10:29 AM
tobarstep tobarstep is offline
Regular Contributor
 
Join Date: Sep 2008
Location: Florida
Posts: 54
Default Re: On Record Start Page Usage-repeating a set of conditions

If you can change the names of your pages so they are more standardized (remove the word "layout" from the "1 For" page names and add the word "1For" to the beginning of those page names which would bring them more inline with the "2For" and "3For" pages) you could use a simplified function like this:

Code:
var pageName;
var dollarAmt = Field("DollarAmount");
var unitOfSale = Field("UnitOfSale").replace(" ","");
 
if (dollarAmt>=20){
 pageName = "TwentyPlusPricing";
}else if (dollarAmt==11){
 pageName = "DollarAmountEleven";
}else if (dollarAmt>=10){
 pageName = "DoubleDigitPricing";
}else if (dollarAmt==1){
 pageName = "DollarAmountOne";
}else{
 pageName = "LessThanOneDollar";
}
FusionPro.Composition.SetBodyPageUsage(unitOfSale + pageName, true);
I also noticed that given the current setup, prices between 2 and 9 are going to return "LessThanOneDollar".

EDIT: Or rather, prices between 2 and 9 won't return a value given the original setup but would give "LessThanOneDollar" in mine. Just change it to >=1 in that test.
__________________
FusionPro 6.0P1f Desktop/Server
Windows XP SP3/Windows 2003
Acrobat 8

Last edited by tobarstep; August 19th, 2009 at 10:31 AM..
Reply With Quote
  #5  
Old August 19th, 2009, 11:29 AM
anthony.bice anthony.bice is offline
Junior Community Member
 
Join Date: Jun 2009
Location: Houston Texas
Posts: 15
Default Re: On Record Start Page Usage-repeating a set of conditions

Thank You Both,
I am working with esmith's "Nested If" approach now. I will digest tobarstep's
Fuction soon. Thanks all so much. I'm trying to slowly understand all points and implement myself rather than copying/pasting your offered solutions.
__________________
Anthony Bice
Pointsmith LLC - Houston, TX
FP 6.2P1a, MAC OSX 10.5.8, Acrobat 9.3.2
Reply With Quote
  #6  
Old August 19th, 2009, 11:30 AM
esmith's Avatar
esmith esmith is offline
Senior Contributor
 
Join Date: Oct 2008
Location: Charlotte, NC
Posts: 428
Default Re: On Record Start Page Usage-repeating a set of conditions

Touché tobartep. I knew a more concise answer lay somewhere amidst all the repetitive words in the preceding solutions!
__________________
Eric Smith
Prepress Guru
Classic Graphics
FP 7.0P1d, MAC OSX 10.6.4, Acrobat 9.3.3
Reply With Quote
  #7  
Old August 19th, 2009, 11:36 AM
tobarstep tobarstep is offline
Regular Contributor
 
Join Date: Sep 2008
Location: Florida
Posts: 54
Default Re: On Record Start Page Usage-repeating a set of conditions

Oh, please don't think I was trying to one-up you I think both approaches will work the same. It's more of a personal preference thing; I like to use variables as much as possible.
__________________
FusionPro 6.0P1f Desktop/Server
Windows XP SP3/Windows 2003
Acrobat 8
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 02:40 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
(c) 2010, Printable Technologies™, Inc.