Out of curiosity, how doe the above script fail for you? It looks correctly designed to change the color of the text in the Action field of the current record on your layout.
I'd be inclined to use conditional formatting instead of physically altering the text color of text in the field.
Your button script would read something like this:
Set Variable [$$ColorFlag ; Not $$ColorFlag ]
Format the field to display text in one of the two colors. Then use this conditional format to change the color to the other:
The key difference here, besides the fact that the conditional format leaves your data unmodified and your script does not, is that this change will affect the displayed color of the text in your field for all records in your found set.
This method will likely fail with your current records until you do this:
Show All Records
Put the cursor in the Action field
Then use Replace field contents with this calculation:
TextFormatRemove ( MANAGER::ACTION )
This will remove all current color formatting--which will otherwise supercede any text color specified for the layout's field object.
Thank you Phil for your fast response.
The Set Variable - ColrFlag looks interesting, however, if this does change all records of the found set I can not use this.
If the headline is of red, the font will change to black by straight jumping to the Else-script. The script fails by not recognizing the black font, hence not changing the black font color to red.
The TextColor ( text ; RGB ( red ; green ; blue ) is basically made to change the color of text. I think, the function fails by changing it to TextColor ( text = RGB ( red ; green ; blue ), as I did to recognize a text color does not work.
Maybe there is an other possibility to make the If step popery recognize the color of the font and subsequently make the correct color swap?
Best regards, Bernd
if this does change all records of the found set I can not use this.
It does not change any data, only how it is displayed.
I now see the problem. MANAGER::ACTION = RGB (0 ; 0 ; 0) will always evaluate as False. RGB "Returns an integer number from 0 to 16777215" and this is very unlikely to equal the value in the action field.
Use this expression instead:If [ Not PatternCount ( GetAsSVG(MANAGER::ACTION ) ; "color: #FF0000" ) ]##FF0000 is the color RGB ( 255 ; 0 ; 0 ) or the color "red" so you are checking to see if the color is not red.
Thank you Phil, this did do the trick!
I'm a simple scripter, hence was not acquainted with the SVG format attributes. Very usefull tip of yours. I will use GetAsSVG(text) in future to look-up text formating that I than can use for conditional text scripting as the one above.
Thanks again, Bernd