MacFileman Posted February 7, 2013 Posted February 7, 2013 Hi... I have used FM for a long time, but have not programmed this calculation in quite a long time or dealt with many text functions. Project Overview is Name Badges...easy enough. Some names are longer than others (of course they are!) so I am using text formatting to control the font size. I know these text codes, so this is more of a general question and I am a horrible explainer, so I will try here. For example... Font size is less than or equal to 20, return 20 Font size is between 21 and 25, return 18 Font size is between 26 and 30, return 16 Etc, Etc, Etc My question is rather general and can apply to many calculations... How do I code these variables generally speaking? I have a field to obtain the character count (Length (Field Name))... etc. Example... Test Size (NAME ; Case (Name Length > 20, 20) If it is between 20 and 30 return this... etc, etc etc Haven't done that in a while and I am spacing!! Thanks for reading and special thanks for helping!!! Mike
webko Posted February 7, 2013 Posted February 7, 2013 I'd build a Case statement: Case ( Name Length < 21; "20"; Name Length < 31; "18"; Name Length < 37; "16"; "10" ) This will return the first matching or the final default value... 1
MacFileman Posted February 7, 2013 Author Posted February 7, 2013 Thank You!!! I have done this before.. but I haven't built a statement like that in about 5 years... my mind froze!! This should do the trick! Thanks for the super fast response!
MacFileman Posted February 7, 2013 Author Posted February 7, 2013 Thanks... worked perfectly! And this can apply to millions of calculations... I didn't "step it" correctly, I did it with the higher value and worked down, that's where I went wrong. I needed to start with the lower numbers and go up.
MacFileman Posted February 7, 2013 Author Posted February 7, 2013 Ughhh..... any thoughts on this dilemma? Out of nowhere... a random name that is low on characters seems to default to a random font size. For the most part it is perfect... it seems to be some kind of weird "flaw."
MacFileman Posted February 7, 2013 Author Posted February 7, 2013 Here is my exact calculation...I also added text styles. Company = name of the company. Company Length = character length of that specific field. TextStyleAdd ( TextSize ( Company ; Case ( Company Length < 35 ; 14; Company Length < 38 ; 13; Company Length < 41 ; 12; Company Length < 45 ; 11; Company Length < 55 ; 10; Company Length < 56 ; 9; Company Length < 60 ; 8 )) ; Plain ) Character lengths range anywhere between 5 and 60, so I am trying to control the font size to avoid line breaks. It works great, but randomly a name with like 5 or characters becomes 12 pts in fonts size. Baffled!!!
Vaughan Posted February 7, 2013 Posted February 7, 2013 Remember that the character count includes while space -- tabs, returns, spaces etc. IMHO don't create a calc field for this, or apply formatting to the actual data. Instead use conditional formatting to change the way the text is *displayed* in the field on the layout. 1
MacFileman Posted February 7, 2013 Author Posted February 7, 2013 The data file is clean of tabs and returns... I triple checked....clean as a whistle! It does have spaces between the first and last name. A typical name might be "John Doe, DR" but I am still getting varied results. When this happens to me, I usually restart from scratch, so I did that. I took it a step further, I even programmed every character length to every font size I want. I am still getting an occasional blip in the result with an odd font size. I have been programming in FM for years. I rarely need coding for a step and repeat/greater than less than structure like this and I rarely ever calculate text formats, but in this case I need to. I have thousand s of names for name badges, so if I don't code this in FM, it would have to be done manually/visually. For the most part, 95% come out correct... but there are a few lines that are not following the rules in the calculation and I am puzzled. I am going to sleep and start from scratch in the morning again. Three times a charm!
MacFileman Posted February 7, 2013 Author Posted February 7, 2013 Current Calculation.... (yes, this is "over" programmed... but due to the inconsistencies I've been getting) TextStyleAdd ( TextSize ( Badge Name ; Case ( Badge Length < 5 ; 21; Badge Length < 6 ; 21; Badge Length < 7 ; 21; Badge Length < 8 ; 21; Badge Length < 9 ; 21; Badge Length < 10 ; 21; Badge Length < 11 ; 21; Badge Length < 12 ; 21; Badge Length < 13 ; 21; Badge Length < 14 ; 21; Badge Length < 15 ; 21; Badge Length < 16 ; 21; Badge Length < 17 ; 21; Badge Length < 18 ; 21; Badge Length < 19 ; 21; Badge Length < 20 ; 21; Badge Length < 21 ; 21; Badge Length < 22 ; 21; Badge Length < 23 ; 20; Badge Length < 24 ; 20; Badge Length < 25 ; 19; Badge Length < 26 ; 18; Badge Length < 27 ; 17; Badge Length < 28 ; 17; Badge Length < 29 ; 16; Badge Length < 30 ; 16; Badge Length < 31 ; 15; Badge Length < 32 ; 15; Badge Length < 33 ; 14; Badge Length < 34 ; 14; Badge Length < 35 ; 13; Badge Length < 36 ; 13; Badge Length < 37 ; 13; Badge Length < 38 ; 12; Badge Length < 39 ; 12; Badge Length < 40 ; 12; )) ; Bold ) & ¶ & TextStyleAdd ( TextSize ( Company ; Case ( Company Length < 5 ; 14; Company Length < 6 ; 14; Company Length < 7 ; 14; Company Length < 8 ; 14; Company Length < 9 ; 14; Company Length < 10 ; 14; Company Length < 11 ; 14; Company Length < 12 ; 14; Company Length < 13 ; 14; Company Length < 14 ; 14; Company Length < 15 ; 14; Company Length < 16 ; 14; Company Length < 17 ; 14; Company Length < 18 ; 14; Company Length < 19 ; 14; Company Length < 20 ; 14; Company Length < 21 ; 14; Company Length < 22 ; 14; Company Length < 23 ; 14; Company Length < 24 ; 14; Company Length < 25 ; 14; Company Length < 26 ; 14; Company Length < 27 ; 14; Company Length < 28 ; 14; Company Length < 29 ; 14; Company Length < 30 ; 14; Company Length < 31 ; 14; Company Length < 32 ; 14; Company Length < 33 ; 14; Company Length < 34 ; 14; Company Length < 35 ; 13; Company Length < 36 ; 13; Company Length < 37 ; 13; Company Length < 38 ; 12; Company Length < 39 ; 12; Company Length < 40 ; 12; Company Length < 41 ; 11; Company Length < 42 ; 11; Company Length < 43 ; 11; Company Length < 44 ; 11; Company Length < 45 ; 11; Company Length < 46 ; 11; Company Length < 47 ; 11; Company Length < 48 ; 11; Company Length < 49 ; 11; Company Length < 50 ; 11; Company Length < 51 ; 10; Company Length < 52 ; 10; Company Length < 53 ; 10; Company Length < 54 ; 10; Company Length < 55 ; 9; Company Length < 56 ; 9; Company Length < 57 ; 9; Company Length < 58 ; 9; Company Length < 59 ; 9; Company Length < 60 ; 9; )) ; Plain ) & ¶ & TextStyleAdd ( TextSize ( City Line ; Case ( City Length < 5 ; 14; City Length < 6 ; 14; City Length < 7 ; 14; City Length < 8 ; 14; City Length < 9 ; 14; City Length < 10 ; 14; City Length < 11 ; 14; City Length < 12 ; 14; City Length < 13 ; 14; City Length < 14 ; 14; City Length < 15 ; 14; City Length < 16 ; 14; City Length < 17 ; 14; City Length < 18 ; 14; City Length < 19 ; 14; City Length < 20 ; 14; City Length < 21 ; 14; City Length < 22 ; 14; City Length < 23 ; 14; City Length < 24 ; 14; City Length < 25 ; 14; City Length < 26 ; 14; City Length < 27 ; 14; City Length < 28 ; 14; City Length < 29 ; 14; City Length < 30 ; 14; City Length < 31 ; 14; City Length < 32 ; 14; City Length < 33 ; 14; City Length < 34 ; 14; City Length < 35 ; 13; City Length < 36 ; 13; City Length < 37 ; 13; City Length < 38 ; 12; City Length < 39 ; 12; City Length < 40 ; 12; City Length < 41 ; 11; City Length < 42 ; 11; City Length < 43 ; 11; City Length < 44 ; 11; City Length < 45 ; 11; City Length < 46 ; 11; City Length < 47 ; 11; City Length < 48 ; 11; City Length < 49 ; 11; City Length < 50 ; 11; City Length < 51 ; 10; City Length < 52 ; 10; City Length < 53 ; 10; City Length < 54 ; 10; City Length < 55 ; 9; City Length < 56 ; 9; City Length < 57 ; 9; City Length < 58 ; 9; City Length < 59 ; 9; City Length < 60 ; 9; )) ; Plain ) If I still have problems tomorrow.... I will go the conditional format route and just code the font sizes. I was hoping to have all the data in one field, but I could technically have 3 fields stacked easily enough. Line 1: Name is Bold Line 2: Company is plain Text Line 3: Location is plain Text Thanks to all for reading my post and a special thanks for the responses. The hidden beauty in this forum is I posted my question and had a response within 5 minutes.... LOVE IT!!! File Maker People ROCK! Mike
bruceR Posted February 7, 2013 Posted February 7, 2013 There is no need for your character at a time method. I agree with the other suggestions that this should be conditional formatting, NOT be part of the field itself. Are the length fields defined as number result?
Recommended Posts
This topic is 4364 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 accountSign in
Already have an account? Sign in here.
Sign In Now