Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Why are TextColor and TextFont not working for me?

Featured Replies

I have a calculation field called 'zpastableMESSAGE' the entire content of whose calculation is as follows:

TextSize ( TextColor (TextFont (zMESSAGE ; zMessageTextFont ) ; zMessageTextColor ) ;zMessageTextSize)

(1) the field 'zMessageTextSize' is a text field, and whatever numeric value I enter into it is being used as TextSize, and correctly changes the size of the text displayed in the field 'zMESSAGE'

(2) the Calculation fields 'zMessageTextColor' and 'zTestMessageTextFont' at present contain values RGB(0,128,0) and "Krazy Kracks NF" respectively, BUT ARE BEING IGNORED (that is, the text in field 'zMESSAGE' is NOT HAVING those values applied).

But, if I replace those fields with the values that are currently in those fields, like this IT WORKS:

TextSize ( TextColor (TextFont (zMESSAGE ; "Krazy Kracks NF" ) ; RGB(250;0;0) ) ;zMessageTextSize)

Why would the Calculation fields not work when their values do?  A copy of a calculation that works would greatly help me.

Thanks in advance.   Philip Caplan

16 hours ago, philipcaplan said:

Why would the Calculation fields not work when their values do? 

Because there is a difference between literal text and formula.

If some field - be it a calculation field or a regular field - contains the text RGB(250;0;0) and you try to use this field in a calculation as: 

TextColor ( "any text" ; SomeField )

then Filemaker will interpret this as:

TextColor ( "any text" ; "RGB(250;0;0)" )

(note the quotes). Then Filemaker will try and convert the text "RGB(250;0;0)" to a color number and get a result of -25000. And since negative numbers are meaningless in this context, the color will be the default 0, i.e. black.

OTOH, when you do:

TextColor ( "any text" ; RGB ( 250 ; 0 ; 0 ) ) 

Filemaker will interpret the second argument as a formula that needs to be evaluated further, and interpret this as:

TextColor ( "any text" ; 16384000 ) 

giving your text a bright red color.

 

To give you a simpler example, suppose you have a text field that contains the text 2 + 2. Using this field in a calculation as =

10 + Textfield

will return 32, same as:

10 + "2 + 2"

would.

I hope this doesn't add further confusion to the issue, but it needs to be mentioned that Filemaker has a function for converting literal text to a formula. In the current example:

10 + Evaluate ( Textfield )

will return 14.

 

All of the above applies to the TextColor() function. I don't think you should have any problems supplying the font name as literal text.

 

Edited by comment

  • Author

I think I've got it to work!!   I used the following calculation:

TextSize ( TextColor (TextFont (zMESSAGE ; zMessageTextFont ) ; Evaluate(zMessageTextColor) ) ;zMessageTextSize)

Thank you.

 

But is it a good solution? I suspect it's unnecessarily complicated. How come you have a calculation field that returns a formula that needs to be evaluated, instead of returning the actual value required? 

Create an account or sign in to comment

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.