Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

This topic is 7267 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

Hi

I am having a little trouble getting a calculation to work as I want/need. I hope someone canhelp me.

I have two fields called [name] and [name2]

When a designed list with only field [name2] is visible is sorted by the name, I would like the text to change from grey plain text to red bold text.

I have made this calculation:

Case (

SetSort = "A" ; TextStyleAdd ( Name ; Bold ) ;

SetSort = "B" ; TextStyleAdd ( Name ; Bold ) ;

TextStyleRemove ( Name ; Bold )

)

This make the text bold. But I cannot cange the text to red also - I have tried with [&] and [and] but nothing work.

Any ideas ?

Jens Peter

Posted

Hi Jens,

You want Name to stay it's original color if sorted by SetSort A but change to red bold if sorted by B? I'm a bit unclear by looking at your calculation so I'll just give you the correct thinking and syntax on it. I'll use If() instead of Case() because it produces a clean example:

If(SetSort = "B"; TextColor(TextStyleAdd(Name; Bold); 13434880); Name)

This will produce red bold on Name when sorted by B, but will leave the field its original color when SetSort is anything other than B. Your SetSort field can be a global (I was presuming it was).

If you wish, you can add the below calculation directly on your Name and Name2 fields as Auto-Enter (and still use your SetSort globals) and eliminate the new calculation field entirely. In that case, you need to force-remove the styles, like so:

If(SetSort = "B"; TextColor(TextStyleAdd(Name; Bold); 13434880);

TextColor(TextStyleRemove(Name; Bold); 0))

Just be sure to unclick 'Do No Replace Existing Values' below the calculation on the Auto-Enter tab and you would need to change that color number 0 to your grey color. You can adjust (and expand) your calculation accordingly using Case(). I assumed your problem was where and how to wrap the color - been there done it. smile.gif

Oh. blush.gif I suppose I'll get jumped on because I didn't use the TextColor ( text ; RGB ( red ; green ; blue ) ) structure. Well, I find it harder to work with than simply converting the color numbers and then using them within a calculation. And I believe this way is a bit faster in evaluation also. If I was teaching how to use colorizing, I'd teach the numbers, not the RGB() function. crazy.gif

LaRetta

Posted

Perfect - I will not tell how much time I have been playing around, becuase I was sure it was possible.

Thank you so much, LaRetta

I just have one questions - how do you define the colour. I can understand the colour is the number but this number comes out of nowhere B)-) the normal colour will be defined as R 170 G 0 B 0

Again thank you so much - it really helped me

Jens Peter

Posted

blush.gif Jens,

I haven't figured out a quick way. Mathematicians can whip out the calc in nothing flat and I have it written somewhere - but (for me) this is the easiest way...

I have a Developer file (that I use for many other things as well), and I added global fields RED, GREEN and BLUE on a layout. And an unstored calculation (number) of:

RGB ( RED; GREEN; BLUE ) ... pointing to these three globals.

This calculation will change depending upon the numbers I put into the global fields. That's the number to use in this conversion.

So I select a field and Format > Text Color and select 'other color'. Drag until I get the color I want. Take those three figures listed in the color box lower right (Red, Green, Blue) and enter them into my Developer file to tell me the number. tongue.gifgrin.gif

I also convert my regular colors to Custom Functions so I don't have to remember the numbers either and I maintain color consistency throughout my solutions. So I can just grab RED(text) whenever I want, anywhere I want; without having to go back to my Field Definitions in some table to find how I did it last time. Me bad.

LaRetta

Posted

LaRetta

That was a quick reply - better then any hotline.

I have a Developer version of FM 7. Is there anyway you would consider sharing an FM file that would show me this option - I am not sure I understand what you are explaining - it sure sounds as a easy way.

The first thing I do when opening a file is adding the different colours I use in that file - if there is any way of skipping this it would really be a time-saver for me.

For the calculation I have just replaced it with the standard colour of RGB.

Everything is working just as I want it to.

Again thank you so much.

Jens Peter

Posted

FMP help > Functions reference (alphabetical list) > Text formatting functions:

Examples

TextColor("Plaid";RGB(255;0;0)) returns the word Plaid in red.

TextColor("Plaid";RGB(0;255;0)) returns the word Plaid in green.

TextColor("Plaid";RGB(0;0;255)) returns the word Plaid in blue.

TextColor("Plaid";RGB(0;0;0)) returns the word Plaid in black.

...

The RGB function uses the following formula to calculate the result:

red * 256^2 + green * 256 + blue

where 2562 = 65536

Posted

wow...

no it gets a little complicated.

The textcolor examples are from the help file (that I have found)

I will play around with your idea and try getting it to work.

Thank you for helping me understand the secrets in FileMaker.

My absolute best wishes

Jens Peter

Posted

Okay, down-and-dirty file with Custom Function. I don't turn all text style functions into CFs but they are much easier to work with. I also added my method of converting the colors. JT gave me a very nice explanation (it has to do with 16.7 million colors). I could find it if anyone is interested.

But I'm basically very lazy and like using Custom Functions for my regular text style and colorizing needs.

As you will see in the example, it's easier when writing a calculation to grab a CF style/color. I used Choose() for the calc because I adore Choose() and it's fastest for me - I'm heading out the door to take my dawg hiking!!!

I hope this is useful. smile.gif

Just saw Comment's post. Yeah, I worked on text styles for a hundred hours to understand them all. And then turned right back to my shortcuts. I'd rather let FM calculate it using RGB. I don't even know what that silly little ^ means. blush.gif

Easy to write out for you math people ... hard for us regular folks to grasp! It's on my TTD list, however. Along with a thousand other math tasks.

LaRetta

coloring.zip

Posted

I was hoping it would make it easier, not more complicated.

The RGB() function does the color calc for you, so all you need to do is enter the RGB values. For example this blueish bar on the left is RGB ( 237 ; 243 ; 254 ).

Posted

Jens, this thread is for you so please pardon my jumping back in but I can't stand it ...

Okay. How did you know the color of the bar? Did you copy it onto clipboard and paste back into FM layout and place a color swatch over it until you matched the color exactly or what? This is a biggie time-saver if you have a shortcut here!

And I have nothing against using the full TextColor ( text ; RGB ( red ; green ; blue ) ) syntax and believe that everyone should understand it. It's like ... everyone should know how to add manually on paper but, good Lord, use a calculator whenever possible - that's what God invented them for - to replace those little ^ symbols. smile.gif

When I am using a bunch of styles together - along with other complexities in a calculation, I kept getting lost in the parenthesis/wrapping issues. crazy.gif And I've even learned to split my calcs up - each piece on another line for clarity and I STILL get hung up many times with the complexity these TextColor with Styles adds to a calculation.

Why do I have the feeling you are biting your tongue or shaking your head again; if ever so slightly? wink.gif

There is more in heaven and earth than what I know so I'm listening if you have something to say about it. All I know is that I struggled for 120 hours to figure this out - only to find myself reverting right back to my shortcuts for simplicity. And I know that I've seen many people on FM Forum struggling with them also but, bottom line, I want to know the BEST ways always.

Now my dawg is mad. Gotta run!

LaRetta

Posted

This may be be a Mac-only thing, but if I am in Layout mode, and I choose Other Color... I get a color picker. It has a little magnifying glass. I click that, and I can grab any color from anywhere on the screen. The picker, if in RGB mode, displays the curent RGB values.

For myself, TextColor ( text ; RGB ( red ; green ; blue ) ) is as simple as it gets. Maybe that's because I am pretty used to the 8-bit RGB color concept. So I don't really need a computer to tell me that RGB ( 255 ; 0 ; 255 ) is magenta, for example. OTOH, TextColor ( text ; 13434880) is utterly incomprehensible, and worse, if I need to change it, I need to perform the RGB() calc myself first. So which one of us is the lazy one?

Posted

We with windows get no little magnifying glass. None. Nada. crazy.gif

OTOH, TextColor ( text ; 13434880) is utterly incomprehensible

Point well taken. But can your mind truly visualize what color RGB(306;121;214) is without turning back to the computer either? 13434880 needs no math conversion anyway because simply selecting that color anywhere in FM (drop cursor into colored text field or select label in layout mode), provides it's RGB equivalent in the (magifying glass on Mac and glass-less on Windoz) color dialog.

I still plan to use the color conversion number because I believe it's more efficient. And, since once I have the number turned into a CF, I won't have to convert over and over again anyway. But one could just as simply use the proper RGB() syntax in the CF or regular calcs. Again, I believe everyone should learn it.

Oh, Custom Functions makes such a difference in writing color/style calculations. Just comparing the first part (and this is only HALF of a two-test If() statement folks) ...

Full Proper

If(SetSort = "B"; TextColor(TextStyleAdd(Name; Bold);RGB(205;0;0));

Custom Function

If(SetSort = "B"; Red(GetBold(Name));

Counterpoint. Now, who wins the lazy test? Me! And which calc would be the easiest to write (least incomprehensible) for normal human beings; particularly when mixed into a complex calculation? I think I win that one too. smile.gif

Well, my dawg just packed her bags and left me. She was so mad when she left, her face was RGB(219;69;4)!!!!! grin.gif

LaRetta

Posted

I want to add one other thing, surprised?

I am not happy with the standard red, blue, green colors everyone uses - based upon straight 255. Mine are deeper. Example: My red is 204;0;0 but my blue is 16;70;197. Since my numbers aren't as simple to remember, it's even more important to save these numbers. I have 6 standard colors and 4 Headings in Custom Functions and I've never needed more than that.

LaRetta

Posted

My mind can spot that 306 is more than the maximum 255. Other than that, RGB (255 ; 121 ; 214 ) would be, hm... medium-bright, pinkish magenta?

Regarding the rest, we are really down to personal preferences now, so I suggest we leave it at that.

Posted

For LaRetta and comment

I really started a fight about what colour setting that is the easiest to use.

As LaRetta wrote at some point - we all just want to get to the result as fast as we can leaving the calculations as simple as possible (or something like that).

I will play with your file, Laretta - thank you so much for sharing - I am also a PC user and finding colours and using them are a time consuming function that I hope FM will solve better one day.

It would be nice if you could save a colour for later use when using those special defined ones. As it is now I often find I need to remade (enter the RGB number) the colours.

Thank you both for sharing you way of work - I learn on every line...

Jens Peter

Posted

For LaRetta and comment

I really started a fight about what colour setting that is the easiest to use.

As LaRetta wrote at some point - we all just want to get to the result as fast as we can leaving the calculations as simple as possible (or something like that).

I will play with your file, Laretta - thank you so much for sharing - I am also a PC user and finding colours and using them are a time consuming function that I hope FM will solve better one day.

It would be nice if you could save a colour for later use when using those special defined ones. As it is now I often find I need to remade (enter the RGB number) the colours.

Thank you both for sharing you way of work - I learn on every line...

Jens Peter

Posted

For LaRetta and comment

I really started a fight about what colour setting that is the easiest to use.

As LaRetta wrote at some point - we all just want to get to the result as fast as we can leaving the calculations as simple as possible (or something like that).

I will play with your file, Laretta - thank you so much for sharing - I am also a PC user and finding colours and using them are a time consuming function that I hope FM will solve better one day.

It would be nice if you could save a colour for later use when using those special defined ones. As it is now I often find I need to remade (enter the RGB number) the colours.

Thank you both for sharing you way of work - I learn on every line...

Jens Peter

This topic is 7267 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.