September 12, 201015 yr Hello. I'm recently back to FileMaker and new to the forum, so thanks for any help. I'm trying to do something that I'm sure is fairly simple, but can not seem to wrap my aging brain around it. I want to toggle a the text in a field between two different type styles--plain and bold, for example. I can set button options for the field and use the TextStyleAdd function to change the text to bold, but I'm not sure how to change it back (without setting up a second TextStyleRemove button). I thought I'd use a simple If...Then calculation to change it. Essentially, one that did something like this: Step 1: If (the text is plain) Step 2: Then (change it to bold) Step 3: Else (change it to plain) I can't find a way to return the text style for step one. I thought that there might be something like the TextSize or TextColor functions for the style, but I'm not having much luck. Any ideas?
September 13, 201015 yr I want to toggle a the text in a field between two different type styles--plain and bold, for example. I don't think you can toggle the styles. You'll need a "plain" button to un-bold the text that uses the TextStyleRemove() function. I don't think there is a function that returns the text's formatting, but I might be wrong.
September 13, 201015 yr I don't think there is a function that returns the text's formatting There are two: GetAsCSS() and GetAsSVG(). But it is not quite simple to use them for this.
September 13, 201015 yr Author Thanks, all for the quick responses. To expand on my situation, I will have a list of words on a page. Ideally, the user would select each word they needed to by clicking on it, changing it from plain to bold. In response to Lee: This works great and is a very simple solution. (Actually, you gave a similar response to someone else a few years ago [color:blue]http://www.fmforums.com/forum/showtopic.php?tid/191035/ which I came across researching the topic before I posted. I probably should have realized that I could have adapted that one.) I can make the button clear and position it over the related field, so it looks like you are clicking right on the word. The one small drawback for me is that it requires three separate objects (two fields and a button) for each of the 100-200 different words I have, but it works. In response to comment: [color:green] "There are two: GetAsCSS() and GetAsSVG(). But it is not quite simple to use them for this. " I was able to get this to work by 1. Setting field2 to the GetAsCSS for field1 2. Using PatternCount to see if the word "bold" is in field2 3. Using an If...Else statement to set the style in field1 based on whether field2 had the word "bold" I had hoped to avoid a second field at all by creating a variable that held GetAsCSS(field1) and using PatternCount on the variable. Unfortunately, it looks like PatternCount only works on fields or text. Is a way to do this with only one field? In a related, but more general question, is it better to have more objects that are less complicated, or fewer, more complicated ones? For example, Lee's elegant solution uses three objects with a simple script and calculation. The solution inspired by comment has only two objects, but more involved scripts. In other words, will the final product run better one way or the other? Thanks again for your help. It's much appreciated.
September 13, 201015 yr I had hoped to avoid a second field at all by creating a variable that held GetAsCSS(field1) and using PatternCount on the variable. Unfortunately, it looks like PatternCount only works on fields or text. PatternCount() works only on text - but the text can be in a field as well as in a variable. It would be best if you clarified your overall purpose here; "a list of words on a page" doesn't say much, and marking something you may need later by making it bold is usually not a good idea.
September 14, 201015 yr Author PatternCount() works only on text - but the text can be in a field as well as in a variable. It would be best if you clarified your overall purpose here; "a list of words on a page" doesn't say much, and marking something you may need later by making it bold is usually not a good idea. You are correct, that is pretty vague. But, it is essentially accurate. It is a kind on inspection report where the user would indicate the condition of what they are looking at by using a checklist. There would be major categories, like "Left Rear Tire" which would be selected with a check box. The sub categories "low pressure" "high wear" "cupping", etc. would be listed across. The user would indicate the tire condition by selecting the word, changing its format. The client does not want to use more check boxes, radio buttons, or pull down lists. However, after thinking about what you said, it may be that an underline would work better. Rather than use the TextStyleAdd for the underline style, is there a way to use a script to add a bottom border to the field? I appreciate your thoughts.
September 14, 201015 yr What is the purpose of entering this data into a database? If you have any plans of getting the data out at some point, then you are on the wrong path. Text formatting is not data. It is very difficult to find records where "high wear" is bold, for example. Data should go into fields as values - and text formatting should merely reflect those values.
September 14, 201015 yr However, after thinking about what you said, it may be that an underline would work better. Ok, that's funny. Moon Shadow, is that you?
September 22, 201015 yr Author What is the purpose of entering this data into a database? If you have any plans of getting the data out at some point, then you are on the wrong path. Text formatting is not data. It is very difficult to find records where "high wear" is bold, for example. Data should go into fields as values - and text formatting should merely reflect those values. (Sorry for the delay responding) You are right that designating text by changing the formatting would not make sense, if I would need to be searching for this data. I'm not really collecting this as data. This particular layout is fairly static and self contained and would simply be a printout. Being able to change the text formatting works for my purpose. This is only a part of a larger project. Strictly speaking, what I'm working on is not a typical database, but does take advantage of many of the capabilities of FileMaker, including some relational features and the ability to create a standalone solution. Again, thanks for your help.
September 22, 201015 yr Author Ok, that's funny. Moon Shadow, is that you? Nope, but I'm glad it made you smile. :
September 22, 201015 yr The user would indicate the tire condition by selecting the word, changing its format. Moon Shadow, is that you? Actually you might not be far off. Here is a demo MoonShadow produced when vs. 7 first came out. It seems complex but is actually very simple. It shows ability to control (at Admin level) which fields can be formatted different colors, bold etc and by how much). Some fields SHOULD allow User formatting at times. If you want to use checkboxes of words this won't work but, as you said, if you want to select a word and allow User to make changes, this will work. Style Assistant IIRC, vs. 7 suffered from a few text formatting anomalies (the field would hold the color improperly) so the process could be simplified now. And, with today's functions and capabilities in vs. 11, it could be simplified even further. But I believe that the concept (allow Users SOME formatting control on only SOME fields) is a good one. And it can be attached easily to any file as it stands without need of manipulation.
September 23, 201015 yr Author Thanks. It's nice to know that I'm on the cutting edge of something 6 years old. :
Create an account or sign in to comment