December 31, 201015 yr Hey all, the calculation below allows the text string "END" to stay in position 12. Am I blind or is there a function that does this already? That is constrain a string to a fixed number of spaces. Let ( [ value = 888 ; gap = " " ; <-- SHOULD HAVE 19 SPACE string = value & gap ] ; Trim ( Replace ( string ; 16 - Length ( value ) ; 1 ; "END" ) ) )
December 31, 201015 yr Can you provide a better explanation of what are you trying to achieve? I think you want something like this, but I am not sure: Let ( [ value = 888 ; gap = " < at least 12 spaces > " ] ; Left ( value & gap ; 12 ) & "END" ) Edited December 31, 201015 yr by comment
December 31, 201015 yr Author Thanks, thats much nicer than the Trim and Replace, but I needed to tweak the left value position to be 12 - lengthValue: Let ( [ value = 888 ; lengthValue = Length ( value ) ; gap = " < At least 12 Spaces > " ] ; Left ( value & gap ; 12 - lengthValue ) & "END" ) This is to change the gap between a number, "value" variable form above, and a text string, "END" from above, as the number changes the gap is adjusted to keep "END" in the same position. ex: _ = " ", 888______END 8888_____END 88888888_END 888888888END :-) But this large number won't be a worry.
December 31, 201015 yr I don't think your formula produces the results listed in your example. If you want to keep the total length of the result to 12 (and assuming "END" is a constant), then = Left ( value & gap ; 9 ) & "END" would return those results.
January 3, 201115 yr Author I know one would think that would be so but check this test - just move between the records to see whats happening kind of funny. Something about the spaces maybe? TextControl Copy.fp7.zip
January 3, 201115 yr I know one would think that would be so but check this test - just move between the records to see whats happening kind of funny. Something about the spaces maybe? TextControl Copy.fp7.zip Nothing funny happening. 1. You're not using a monospaced font. Change to something like Courier 2. The calculation differs for records 1-3 vs 4-7. Records 4-7 use the correct calc.
January 3, 201115 yr So are non monospace font spaces worth two positions? There are no "positions" in a variable-width font; every character has its own width - and even this can vary based on the adjacent characters and other parameters. What is your purpose in this calculation?
January 4, 201115 yr Author So by subtracting the field from the total space I am keeping control of position. Display the current record and found count with out the "Found: y/z" moving as x varies. Like the following: Record: x Found: y/z x = current record y = found count z = total record count
January 4, 201115 yr But you already have the solution to this. Calc as specified by Comment, and as found in records 4-7 in your file; Courier font. TextControl.fp7.zip
January 4, 201115 yr Author But you already have the solution to this. Calc as specified by Comment, and as found in records 4-7 in your file; Courier font. COURIER IS NOT A SOLUTION! :-) So yes there is a function you can use to constrain a field to fixed number of spaces but those spaces can have varying width depending on font used - unless monotype. Calc as found in records 4-7 do not work with "Lucida Grande" but they do work with records 1-3. I just wanted to understand what was happening and it has to do with the font width not being fixed - thanks Comment - and my calculation handles this situation - so far. It looks like Left ( ) takes each position away from the left - off course - but when it does it removes spaces that correspond to the width of the characters and since I am subtracting the exact number of characters at the start of the string it works. Or something to that effect. Thanks for the input.
January 4, 201115 yr COURIER IS NOT A SOLUTION! :-) So yes there is a function you can use to constrain a field to fixed number of spaces but those spaces can have varying width depending on font used - unless monotype. Calc as found in records 4-7 do not work with "Lucida Grande" but they do work with records 1-3. I just wanted to understand what was happening and it has to do with the font width not being fixed - thanks Comment - and my calculation handles this situation - so far. It looks like Left ( ) takes each position away from the left - off course - but when it does it removes spaces that correspond to the width of the characters and since I am subtracting the exact number of characters at the start of the string it works. Or something to that effect. Thanks for the input. No, Courier (or an alternative monospaced font) IS the solution - and the ONLY solution - to your chosen approach to your problem: positioning text data with spaces. Your calc doesn't work; Comment's calc does; when using a monospaced font. Since the first word processor - even since the typewriter - using spaces to position text has NEVER been an effective way to format text and it wouldn't be accepted in Keyboarding 101. That's why rulers and tab stops were invented. As Comment has asked - what are you really trying to accomplish?
January 4, 201115 yr Author I just wanted to know if there was a better way to form my original calculation and there was, Comments suggestion to use Left ( ) instead of using the Trim ( Replace ( ) ) I was using. Thanks
January 4, 201115 yr But - as you have mentioned - that does not solve your problem. You've still got variable width text, unless you use a monospaced font. What you CAN do is completely abandon the space sequence, use a tab character, and set tab stops for the field. This would operate independent of font.
January 5, 201115 yr Author But - as you have mentioned - that does not solve your problem. You've still got variable width text, unless you use a monospaced font. What you CAN do is completely abandon the space sequence, use a tab character, and set tab stops for the field. This would operate independent of font. And use merge fields and create more layout objects and more things you have to account individually in each layout, better to sometimes work through Calc's. Also then I can not see a way to sequentially format data nicely as if it were a table or column data in one field, make it a method class - its objectively correct. ! :+) With an if() at min, Case(), or Perhaps Choose() and the gambit of possible functions to use, its possible to align the text in the entire field with varying fonts and static fonts all aligned like a generic word file or what you will. By containing an underlying line length there is always something to measure against. I guess its just a way of automating the formatting processes into one field. Running calculations like this all to run a single inactive/non changeable text field for static or protected data. For one or two liners with filemaker I think this is cool but in reality if want jobs we should be using web viewer with css, javascript, svg even.
Create an account or sign in to comment