Jump to content

Formatting Text (Title Case)


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

Recommended Posts

I received such great help with a problem I posted earlier, I'd like to throw one more out there if I may.

When we import records, the text is all "UPPER CASE". Can I tell FM to select a two fields [First_Name] and [Last_Name], then format all text within every record to be "Title Case"?

Thanks in advance,

Kip

Link to comment
Share on other sites

OK, can't currently think of a way of making this dynamic, but it does work. So if you only want to change a couple of fields this is one eay.

Write a script called Title Case.

Freeze Window

Allow User Abort [on] (only for testing purposes.

Go to record [first]

Loop

Go to field [First name]

Set field [dont specify a field] Proper("First Name")

Go to field [Last Name]

Set field [dont specify a field] Proper("Last Name")

Go to record [next, exit after last

End Loop

This will make those two fields for all the imported data (or the found set have title case)

Someone may come up with a more dynamic way of doing this.

HTH.

Link to comment
Share on other sites

Create a calc field:

Upper(Left(UpperCaseText, 1) & Lower(Middle(UpperCaseText, 2, 100)

Make sure the field is formatted without messing with the upper/lower case settings.

OR...

If all you want is to display the text correctly, in Layout mode, select the field, go to Format/Text and format it as Title Case.

Link to comment
Share on other sites

See,

I knew dan would come up with something. But then Dan why not create a calc field for each field.

Proper(fieldname).

I just took it that he wanted to change the contents of the actual fields, as opposed to creating additional fields.

Link to comment
Share on other sites

You could also use the Replace command, FWIW. In a script it would be:

Replace (No dialog, First Name, Proper(First Name))

Replace (No dialog, Last Name, Proper(Last Name))

Of course, with names like McDonald or MacDonald, you'd need to work a little harder... Take a look here for starters.

Link to comment
Share on other sites

I would use the Proper(Text) command here, too. But I would just use the SetField, and not GoToField step. Dealing with the Mc problem is quite easy too.:

--------------------------------------------------

SetField First_Name

Proper(First_Name)

SetField Last_Name

Proper(Last_Name)

If

Left (Last_Name,2) <> “Mc”]

Exit Script

Else

SetField Last_Name

Left( Name1, 2) & Upper(Middle( Name1, 3, 1)) & Middle( Name1, 4, Length(Name1) - 3)

End If

--------------------------------------------------

Of course you can loop this to deal with the current found count, or if you want use a replace, which is, in itself, faster, but here you would have to replace at least twice. I would consider developing this a bit further, once you’ve got your DB in order, and using it as a validation by calculation. That way you can avoid people messing things up again, as FMP will not allow them to enter data in an incorrect manner.

Hope this helps:

Rigsby

Link to comment
Share on other sites

PS: If you loop this, you will have to change the exit script part:

If

Left (Last_Name,2) <> “Mc”]

Exit Script

However, the reason I did it this way is to avoid “mc ally” for example becoming “McAlly” instead of “Mc Ally”.

But you can simply change the Exit Script, to Go to next record.

Rigsby

Link to comment
Share on other sites

This topic is 7143 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.