Jump to content

Setting Global Variable With Fixed Spaces


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

Recommended Posts

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" ) )

)

Link to comment
Share on other sites

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 by comment
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This topic is 4415 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
 Share

×
×
  • Create New...

Important Information

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