Subscribe Bookmark RSS Feed

Proper Syntax for Table Preferences

frankeberle

Community Trekker

Joined:

Jun 2, 2016

I have a script that appends data to a journal but I would like to color the table numbers based on the value.  I know there is away to color by doing the following:

Preferences(
Conditional Formatting Rules(
RuleSet(
RuleName( "Yield Check" ),
GreaterThan( Value( 70.0 ), Inclusive( 1 ), Format( Text Color( "Black" ), FontStyle( Bold ), Back Color( 73 ) ) ),
GreaterThan( Value( 85.0 ), Inclusive( 1 ), Format( Text Color( "Black" ), FontStyle( Bold ), Back Color( 4 ) ) ),
LessThan( Value( 70.0 ), Inclusive( 0 ), Format( Text Color( "Black" ), FontStyle( Bold ), Back Color( 3 ) ) )
)
)
);

 

The problem is that the script doesn't evaluate the second GreaterThan line. I know you can go into the prefeneces settings and edit the rule manually but I would like to do this in script.  I just want to know if there is a way to code in 70< x < 85 turns yellow. 

 

Thanks for the help.

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson

Super User

Joined:

Jun 22, 2012

Solution

You can only have one Greater Than clause.  To handle your between group, you need to use a Range.  Here is an example:

Preferences(
	Conditional Formatting Rules(
		RuleSet(
			RuleName( "Yield Check" ),
			LessThan( Value( 70 ), Inclusive( 0 ), Format( Text Color( "Red" ), Back Color( "White" ) ) ),
			Range(
				MinValue( 70 ),
				MaxValue( 85 ),
				InclusiveStart( 1 ),
				InclusiveEnd( 0 ),
				Format( Text Color( "Red" ), Back Color( "White" ) )
			),
			GreaterThan(
				Value( 85 ),
				Inclusive( 0 ),
				Format( Text Color( "Medium Light Blue" ), Back Color( "White" ) )
			)
		)
	)
);

The easy way to get the correct syntax for this, is to interactively create the conditional format, and then to run the code to retrieve the preference

Names Default To Here( 1 );
a = Preferences[1] << Get(
	Conditional formatting rules
);
Show( a );
Jim
1 REPLY
txnelson

Super User

Joined:

Jun 22, 2012

Solution

You can only have one Greater Than clause.  To handle your between group, you need to use a Range.  Here is an example:

Preferences(
	Conditional Formatting Rules(
		RuleSet(
			RuleName( "Yield Check" ),
			LessThan( Value( 70 ), Inclusive( 0 ), Format( Text Color( "Red" ), Back Color( "White" ) ) ),
			Range(
				MinValue( 70 ),
				MaxValue( 85 ),
				InclusiveStart( 1 ),
				InclusiveEnd( 0 ),
				Format( Text Color( "Red" ), Back Color( "White" ) )
			),
			GreaterThan(
				Value( 85 ),
				Inclusive( 0 ),
				Format( Text Color( "Medium Light Blue" ), Back Color( "White" ) )
			)
		)
	)
);

The easy way to get the correct syntax for this, is to interactively create the conditional format, and then to run the code to retrieve the preference

Names Default To Here( 1 );
a = Preferences[1] << Get(
	Conditional formatting rules
);
Show( a );
Jim