Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

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

Recommended Posts

Posted

Hi guys,

Has anyone every come accross a formula that will text format a field like so

The user inputs:

my name is david.i live in a town.Please vist me

And the format output from the formula

My name is david. I live in a town. Please vist me

All i want really is the first letter of every sentence capitalized and there be a space after every .

Any help very much appriated.

D

Posted

I don't know about doing it by calculation, but with an additional field, a global number field called counter, I think this script would do it for you:

Set Field [ table::counter; 1 ]

Set Field [ table::field; Upper ( Left ( table::field; 1 ) ) & Right ( table::field ; Length ( table::field ) - 1 ) ]

If [ PatternCount ( table::field ; "." ) ]

Loop

If [ Middle ( table::field ; Position ( table::field ; "." ; 1 ; table::counter ) + 1 ; 1 ) <> " " ]

Set Field [ table::field; Replace ( table::field ; Position ( table::field ; "." ; 1 ; table::counter ) ; 1 ; ". " ) ]

End If

Set Field [ table::field; Let (

[ PositionCurrentPeriod = Position (table::field ; "." ; 1 ; table::counter ) ;

TextToCurrentPeriod = Left (table::field ; PositionCurrentPeriod) ;

StartingWord = WordCount ( TextToCurrentPeriod ) + 1 ;

WordAfterPeriod = MiddleWords (table::field ; StartingWord ; 1 ) ] ;

Substitute ( table::field ; WordAfterPeriod ; Proper ( WordAfterPeriod ) )

) ]

Set Field [ table::counter; table::counter + 1 ]

Exit Loop

If [ table::counter = PatternCount ( table::field ; "." ) + 1 ]

End Loop

Else

Set Field [ table::field; Replace ( table::field ; 1 ; 1 ; Proper ( LeftWords ( table::field ; 1 ) ) ) ]

End If

Posted

You could use the substitute function like this:

Middle(Substitute("."&InputText;[" ";" "];[". ";"."];

[".a";". A"];[".b";". B"];[".c";". C"];[".d";". D"];

[".e";". E"];[".f";". F"];[".g";". G"];[".h";". H"];

[".i";". I"];[".j";". J"];[".k";". K"];[".l";". L"];

[".m";". M"];[".n";". N"];[".o";".O"];[".p";". P"];

[".q";". Q"];[".r";". R"];[".s";". S"];[".t";". T"];

[".u";". U"];[".v";". V"];[".w";". W"];

[".x";". X"];[".y";". Y"];[".z";". Z"]);3;10000000)

Posted

SWEET!! I didn't know you could pass multiple parameters like that!

Incidentally, you kill all the spaces. Take out the [" ";""] parameter, and you're good to go though, except for the "existing space after period" issue. I'm going to have to work the brackets in other functions and see what happens.

I love this forum...

Posted

Yeah, I noted the glitch after I posted. I went back and edited the previous post to fix it. But, you must have already got the old one. The intention was to replace double blanks with a single one, because excess spaces could mess up the calculation.

The ability to use multiple sets of search/replace strings in the Substitute function is new with version 7. With version 6 and earlier, you can still accomplish the same thing by nesting Substitute functions, but it's not as clean looking.

Posted

TrimAll( text; 0; 0 ) will change any multiple spaces into single ones and remove any leading and trailing ones. Just an FYI.

Posted

This newfangled version 7 has been sitting in the box here for the past 10 months. So, now that I finally got it installed, I'm finding all sorts of clever new functions. Had a look at the TrimAll function a couple of weeks ago, but for some reason I didn't think it would do that. Thanks for pointing it out.

Posted

Noticed there's still little problem with the formula in a couple of situations. Here is a fixed version:

Middle(Substitute(TrimAll(". "&Substitute ( InputText ; "." ; ". " );0;0);

[". a";". A"];[".b";". B"];[".c";". C"];[".d";". D"];

[". e";". E"];[". f";". F"];[". g";". G"];[". h";". H"];

[". i";". I"];[". j";". J"];[". k";". K"];[". l";". L"];

[". m";". M"];[". n";". N"];[". o";".O"];[". p";". P"];

[". q";". Q"];[". r";". R"];[". s";". S"];[". t";". T"];

[". u";". U"];[". v";". V"];[". w";". W"];

[". x";". X"];[". y";". Y"];[". z";". Z"]);3;10000000)

Posted

No wonder "Using FileMaker 7" is about a foot and a half thick and weighs around 150 pounds.

Hey! My copy doesn't even say anything about TrimAll! It's got a Trim, and a TrimChar (which would do the trick too), but no TrimAll. I guess if they included everything, it'd be 2 feet thick and 200 pounds.

Posted

TrimChar is not a function in FM 7, unless it's possibly for a different region/language?

Posted

Oh, never mind. I looked again, it's an example of a custom function. They done made it up...

Still no mention of TrimAll, though. What do the TrimSpace and TrimType parameters mean?

Posted

Hi guys thanks for all the input its great really works a charm.

here is a newer vesion as b c d were formatted funny last time.

fmforums rule.

D

Middle(Substitute(TrimAll(". "&Substitute ( Input Text ; "." ; ". " );0;0);

[". a";". A"];[". b";". B"];[". c";". C"];[". d";". D"];

[". e";". E"];[". f";". F"];[". g";". G"];[". h";". H"];

[". i";". I"];[". j";". J"];[". k";". K"];[". l";". L"];

[". m";". M"];[". n";". N"];[". o";".O"];[". p";". P"];

[". q";". Q"];[". r";". R"];[". s";". S"];[". t";". T"];

[". u";". U"];[". v";". V"];[". w";". W"];

[". x";". X"];[". y";". Y"];[". z";". Z"]);3;10000000)

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