Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

Posted

Hi all,

Anyone know if it is possible for a script to change the width of a text field in a layout?

I can't find any evidence that you can but just maybe....!

Thanks

Ed

Posted

Ed,

I'm not sure I understan you question. Do you mean to change the size of a field based upon the actual information in that field? So for example, if the field is "first names" then the field would shrink to fit "BOB" or enlarge to fit "MARGARET"?

Assuming that this is what you mean, what you need to do is "slide" your field. In the layout format, highlight the record you want to change. In the pull-down menus, you need to find the "Sliding/Printing" feature. I will admit that I can't think of which pull down menu that is under right now. In any case, it's at the bottom of the pull-down menu. Anyway, if you then click on the button on the left, the sliding button, FMP will shrink the field to fit based on the content of the field for each record. So for example, if you have "first name" and "last name", and on your printout, you want it to look like a normal typing of a person's name, you would highlight BOTH fields, go to "Sliding/Printing" click the left button for Sliding Left. Then, on your printouts, the name would appear as:

JOHN SMITH, not JOHN SMITH. It will still look spread out in the Browse Mode, but will look right in Preview Mode and will print out right.

If this is not what you were referring to, I apologize for wasting your time while you read this monologue!!!

Posted

No that's fine peg, I understand where you going with that but it's not quite what I want to do - I didn't explain very clearly.

The fields in my report layout can change - the user defines what fields they want on a report. Now with the help of a few members in the forum I got it working so that whatever the user selected would show on the report layout.

The actual fields on the layout are case statements so for example if the user said I want the 1st column to be first names then it is set to ReportColumn1Field=First Names.

What I want to be able to do is define how big the text box should be if they selected first names, how big it should be if they selected age etc

Hope this is a bit clearer!

Thanks

Ed.

Posted

There is no direct way to do this, but you can still make use of the sliding/shrinking feature. If you use a monospaced font like Courier, and pad the fields out with spaces so that the fields always have a constant number of characters, then they will remain vertically aligned.

You define a display field like this:

cDisplayField1 = Left(GetField(gFieldSelection1)& gSpaces,gFieldWidth1)

gSpaces is a global text field preloaded with about a hundred spaces.

Then place all your display fields on a list layout, and set them to shrink/slide to the left.

Posted

Hi Bob,

Thanks for your reply, firstly what would gFieldWidth1 contain, not sure what this bit would be for?

And secondly, I kind of get what you are doing here, but lets say gSpaces contained 100 spaces.

If I have a "first names" field and an "address" field. "address" field is nearly always going to contain text that is longer than "first names".

Therefore if it is always adding on 100 spaces the address field is still going to be much longer than the first names field is it not?

Thanks again

Ed.

Posted

gFieldWidth1 would be a numeric value equal the desired width of field. If you want to display 25 characters for the chosen field, then you would set this value to 25.

gSpaces is just a reservoir of spaces. It could be 100 or 10000 spaces. The Left() function will trim the field to the value of gFieldWidth1. The reason why you need to append the spaces before you trim is to pad out field values that are smaller than the required size. Suppose you want the name field to be 25 characters long, but the name in the current record is only 18 characters. If you just print it as 18 characters, then the remaining fields on that line would slide too far. So, you need to add on extra spaces, and then trim to 25. That way all fields in that vertical column will be exactly 25 characters and all fields will line up vertically.

For each field that you want to display across the report you would set up cDisplayField1, cDisplayField2, cDisplayField3, etc., and each of these would have corresponding gFieldWidth1, gFieldWidth2, etc. to set the widths of each field (column).

Posted

Rogue stupid question from a rookie:

I am SURE I can use this - in about 6 months (I am all alone learning FM and working on a new DB with its own problems which I am solving slowly with the help of the Forum, plus I have other IT duties as well - it's a small company). How can I bookmark this thread so I can come back to it - in 6 months - and not bother you experts with the same question again?

I have learned so much from the Forum already - much of which I have to try to retain for when it's appropriate in my learning curve - that I have often wondered about this. (I already know OceanWest or some other savvy user will write back to tell me something I should have known already ...)

Embarrassed blush.gif but thanks - Bonnie

Posted

At the bottom of this page there is a link which says Favourite Thread! (toggle) If you click on this, it will add it to your list of favourite threads on your FMForums home page

Ed.

Posted

thanks Ed! Never noticed that before. Maybe I've been too busy reacting (and - in my own defense - "Favorite thread!toggle" is not exactly intuitive) I've been keeping up with your posts as well (another set to be bookmarked). I really appreciate everything! What a good group of people!

Posted

One more bit of advice for when you use the sliding option in report layouts:

You can add little spacer objects between your fields to ensure that they don't all run together. For example, you can create a tiny little white filled rectangle with no border (so it won't be visible) and place copies of it between each field so that when things slide together, they will have a bit of a gap in between.

  • 2 weeks later...
Posted

Hi Bob,

This is working quite well. I do have one problem though.

I set the font on the report layout to courier, but an alph character is still wider than a space character, therefore when the fields slide together, they are not vertically aligned.

Record 1 and Record 2 may both have 20 characters (using your calculation, which is great by the way!) but as record 1 has 9 space characters at the end whereas record 2 has 1 space character the alignment is all screwed up.

Any more ideas please?

Thanks very much

Ed.

Posted

That doesn't sound right. Monospaced fonts like courier are designed so that all characters, including spaces are exactly the same width, for precisely the reason it is being used here-- so that everything lines up. Could possibly be a FM bug. It wouldn't be the first. You could possibly try using the substitute function to replace the regular spaces with non-breaking spaces (option-space on a Mac, not sure what it is on windows).

IE:

Substitute(TheTextSoFar," ","

Posted

It may be that the data in the field has some formatting that is over-riding the Courier format on the layout.

Posted

Hi all,

There is no formatting on the data so the courier font is definitely being applied.

Bob, I am not sure what you mean by non-breaking spaces, I have never come accross this before and I am on Windows so does anyone know how to do this?

Many Thanks for everyones help on this

Ed.

This topic is 7838 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
×
×
  • Create New...

Important Information

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