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 6518 days old. Please don't post here. Open a new topic instead.

Recommended Posts

  • Newbies
Posted

Hello, all you smartypants.

I'd be most grateful if you could help me with this one.

I'm trying to create a replace calculation based on text, but it only works if the EXACT text is the only thing in the field. In other words, it replaces "wrappers" with "softcover" but it does not replace "illustrated wrappers" or "self-wrappers" with "softcover", as I would like it to.

Can anyone tell me what to put in the calculation to make the replacement whenever the given text exits in the field even if there are other words in the field, or even if it is part of another word?

I've used nesting before, but there are so many variations It'd be a mile long!

THANK YOU!!!

Posted

The answer to your question:

Substitute( DataField , "wrappers" , "softcover" )

The question to see if I am understanding your desired outcome:

Is this a one time, Replace Field Contents (Ctrl + =) operation, acorretion via an auto-entered value, or a calculated value? The addition info will change based on the answer.

Posted

There is also the question of context, ie, wrapper would not be replaced but wrappers would. It would help to have more examples to work with and how it will be used, as Mark says. The other problem with narrowing the replacement to words-within-words is that the wrong word might be replaced. It would not happen in your example but may if other examples are presented. Depending upon the need, I might suggest using a gFrom global text and a gTo global text and a scripted approach; possibly while viewing highlight of possible words to change. If used within an auto-enter, it might make correcting the incorrectly changed words more difficult to fix. Examples of possible problems: Replace wrappers with softcover ...

Original: The wrappers were placed ...

Result: The softcover were placed ...

Original: If the wrapper is 1/4", it should be placed with the other wrappers.

Result: If the wrapper is 1/4", it should be placed with the other softcover.

So not only can the singularity mismatch, but not all of the words will be replaced which will produce illogical sentences. If you replace smaller words, the odds of replacing an incorrect one increase, ie, replace able with capable - would change enable to encapable. :crazy2:

We have a lot more questions than answers for sure. :smile2:

LaRetta

Posted

In truth, it might work best to use Perform Find/Replace. But I would still incorporate that script-step with a good view of highlighted possibilities (using a global to plug in the root word). As you applied Perform Find/Replace, the remaining highlighted words of possible matches, such as root word ending in 'ing' or 'ed', would then stand out for a second round of find/replacing if need be.

  • Newbies
Posted

Hello & thanks. OK:

My database is for my library and my field BINDING is populated with descriptions of my books bindings. I would like to dumb it down, so that the fancy bibliographic terms become simpler: either hardcover or paperback.

Therefore, I'd like for it to translate any field that contains the word "wrappers" (in any incarnation or combination, whether it's self-wrappers or decorative wrappers or wrappers in dust-jacket)to the word "Paperback."

My current replace function translates "wrappers" to "paperback" only if "wrappers" is the ONLY word in the field.

But I would like for it to work in any instance that the word "wrappers" appears in the field. So that:

self-wrappers = paperback

decorative wrappers = paperback

wrappers = paperback

wrapper = paperback

wrappersdelight = paperback

You all are great! thank you!

Posted

You could easily replace any of these rather easily:

wrappers = paperback

wrapper = paperback

wrappersdelight = paperback

With

self-wrappers = paperback

You could add in a check to see if there is a hypen and do this rather easily too.

However with text stings such as:

decorative wrappers = paperback

It may not be that easy because how do you distinguish one word as needing to be replaced verses not. Is this a list of predefined adjectives that you want to replace as part of this?

  • Newbies
Posted

Mr. Vodka:

That's the problem. The list of pre-defined adjectives is rather long. I could enter them all (and do it in a nesting 'if' function), but I'm trying to just find a shortcut so that the entire text in any field containing the word 'wrappers' will become 'paperback' . hmmm

Posted

but I'm trying to just find a shortcut so that the entire text in any field containing the word 'wrappers' will become 'paperback'

This should have been stated earlier.

As Comment pointed out, your replace calc could be just as simple as:

Case ( PatternCount ( YourField ; "wrapper" ); "paperback"; YourField )

If you want to compensate for a cap. letter such as Wrapper, then use

Case ( PatternCount ( Lower ( YourField ) ; "wrapper" ); "paperback"; YourField )

  • Newbies
Posted

Thanks, Mr. Vodka! I'll try that!

(Sorry it wasn't clear before, thanks for your patience, but I thought I stated it here:

"I'd like for it to translate any field that contains the word "wrappers" (in any incarnation or combination, whether it's self-wrappers or decorative wrappers or wrappers in dust-jacket)to the word "Paperback." My current replace function translates "wrappers" to "paperback" only if "wrappers" is the ONLY word in the field. But I would like for it to work in any instance that the word "wrappers" appears in the field.)

Posted

If you want to compensate for a cap. letter such as Wrapper, then use

Case ( PatternCount ( Lower ( YourField ) ; "wrapper" ); "paperback"; YourField )

This is not necessary, since PatternCount() is not case-sensitive.

Posted

Oops forgot. I always get the case sensitivity for PatternCount and substitute jumbled. Thanks Michael.

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