Jump to content

Simple text handling


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

Recommended Posts

Hi,

I'm sure this is really simple, but I can't find anything in the archives and the help is a bit obscure. :

I want to clear some text from a field (which I'm using for 'keywording'). I have no trouble clearing the text string, with substitute, but I want it to only clear the string if it is a whole word. The text field is used for a relationship and it's values are separated with returns.

So ...

If I have :

test

test2

test3

and I want to clear "test" but "test2" and "test3" should remain untouched ... what function do I use?

Also ... while I'm at it ... I can get the words to move up in the text field by replacing any instance of 2 hard-returns next to each other ... but obviously ... when the field starts with a hard-return, there is only one, so it's not removed.

How would I clear this hard-return, so that the text moves up to the top of the field when some words are cleared from it?

Any help/suggestions, much appreciated!

Grant

Link to comment
Share on other sites

Gary,

Do you want to remove a line based upon pattern match to another word or part of the first word (TEXT) or do you want to just always remove the first line?

A custom function isn't needed here but it's handy. I just don't want others (without Developer or Advanced) to think they are limited on this solution. :wink2:

Edited by Guest
Link to comment
Share on other sites

I think the poster is asking for a value to be removed by content whereas the CF is removing a value by its position in the list. The only thing making this at all difficult is the fact that a Filemaker Value list does not have carriage returns at either end. So to remove a single value "string" from a field consisting of a list of values the Substitute function is adequate:

Substitute("¶" & field & "¶";"¶" & "string" & "¶";"¶")

removes string whenever it occurs as a value in the list and inserts the necessary intermediate carriage returns. The problem is that you are now left with carriage returns at both beginning and end so finally we can remove them for example by

Middle(Substitute("¶" & field & "¶";"¶" & "string" & "¶";"¶");2;Length(Substitute("¶" & field & "¶";"¶" & "string" & "¶";"¶")

)-2)

Link to comment
Share on other sites

Do you really think that ?

Don't is more realistic to give to a FMP8 Advanced owner a clear suggestion ?

I think the poster is asking for a value to be removed by content whereas the CF is removing a value by its position in the list

SlimJim - You are right...and your calc is good !

Link to comment
Share on other sites

Daniele,

I wasn't arguing with the suggestion. I was stating that one didn't need a custom function to solve the problem. There are hundreds of custom functions that don't NEED to be CF. They are put there for utility convenience (which is quite legit). Some readers might see reference to custom function and think it couldn't be accomplished without one. That was my only point.

What is this? A full moon? :wink2:

Link to comment
Share on other sites

So you're suggesting that someone should turn a calc into a custom function just because they have the custom function feature? Keep in mind that CFs DO require an additional evaluation (if I understand it correctly). I ran a speed test once with The Shadow's assistance. CFs CAN slow a calculation a bit ...

All of the tools in FileMaker should be used because they are the best tool for the job - not just because they are there.

But you again are missing my critical statement here, Daniele ... that convenience and portability also have their value. I have many calculations and MOST are NOT custom function. Those I use FREQUENTLY are ... for convenience. It's a trade-off. But using resources just because they are there is silly.

I was providing further input and assistance to Grant and now I'm feeling drilled and I don't want to get into a debate. I'm out of this discussion also.

Link to comment
Share on other sites

So you're suggesting that someone should turn a calc into a custom function just because they have the custom function feature?

No, he shouldn't, but why not use ?

Keep in mind that CFs DO require an additional evaluation (if I understand it correctly). I ran a speed test once with The Shadow's assistance. CFs CAN slow a calculation a bit ...

This is a preconcept in this case

All of the tools in FileMaker should be used because they are the best tool for the job - not just because they are there.

But we have to know that they are there

I was providing further input and assistance to Grant and now I'm feeling drilled and I don't want to get into a debate. I'm out of this discussion also.

Ok

Link to comment
Share on other sites

One reason not to use it would be that it is not a very good calculation. It assumes that the list is made up of words only. And using "999999999" is just plain lazy.

SlimJim's formula is much better - if I may say so myself ...

However, IMHO the proper solution would be to move the keywords to a related table.

Then it becomes a simple matter of deleting a portal row - not to mention other advantages of normalizing.

EDIT:

On second thought, I am not sure how that would work with AND finds... something to consider.

Edited by Guest
Link to comment
Share on other sites

Hi everyone ... and thanks for all the replies!!

I was probably not clear enough about precisely what I'm doing ... it's really hard to explain this stuff sometimes.

I took a look at the DeleteValue function and it won't work for me (I don't think so anyway ... but I'm a photographer, not a programmer, so there's a fair chance I'm wrong!). The reason it won't work, is that I'm trying to do 'batch' substitution, based on a portal-relationship.

To this end I have a script, which will replace the return separated values in a text field ... for a group of related records ... however, my problem is in the function logic *and* the fact that the words may be in a different order in different record's fields :

Record 1=

test

test2

test3

Record 2 =

test3

test2

testik

If I run my script at present, to remove the word 'test' and using the 'substitute' function, even with leftwords (I could be using it wrongly) I get :

Record 1=

2

3

Record 2 =

3

2

ik

What I want is :

Record 1=

test2

test3

Record 2 =

test3

test2

testik

I'd also like the text values to 'slide up' to fill the empty space.

___________________________________________

The comment from ... ehh... 'comment', about using a portal for the keywording was quite interesting to me also, because these files are a BIG evolution from files that were originally built in FM2, with a lot of changes made with FM3 and then various improvements made in FM4 and FM5. I decided to move them up to date with FM8, hence the extra cash on the developer vs to help me do so. I've found that having re-thought them carefully (it's just an address/quote/invoice/mail system for my studio) I've now ... un-intentionally made them 100% based on relationships and portals. I don't actually at this point use the files in a direct way, as I've always done in the past.

I have to say that this has worked well ... but I wonder about the structure. For example, this problematic script ... I've found that the 'Replace' script-step, works for a group of records, present in a portal, *but*, only if there is only 1 record in the found-set! You guys all probably know this already ... but ... I've found that applying the Replace script-step, to a group of records is *very* fast and all I have to do is include a Omit found-set, minus 1 thingy and it works a treat.

Now ... the question is ... why do I even have any records in what has become the 'control' pages? Are there other things that would work better, like this, IOW, when the realtionship is always at least 1 file away?

Any pointers on this subject would be very welcome too!!!

Many thanks again for all the replies!

Grant

Link to comment
Share on other sites

Well, now I am utterly confused. Could you give us the real situation, instead of an abstract example? I was convinced by "keywording" you meant adding keywords to photos, i.e. indexing.

I also don't see why the order of values in the field should matter.

'Replace' is now 'Replace Field Contents..' - under Records menu.

Link to comment
Share on other sites

Well ... I mention the text order only because it seems to preclude solutions like DeleteValues, which rely on the ability to delete a value based on a number. Maybe I need to take another look at those, but that's what I understood. I've never used a custom-function so I'm not too familiar with them.

By keywording I did mean indexing, as you put it.

Simple explanation ... I have produced some scripts to 'batch' keyword a group of records, present in a portal, or to 'batch' clear those keywords.

It's the 'clear' bit I'm having problems with, because the substitute function acts on a 'string' and not a word. I can't get it to work on a word and ignore the string ... which may also be present in another word. E.G., the text string; "test" when cleared (substituted) from a field which contains the words

test

testimony

will result in

imony

You see the problem. Like I said, I'm sure this is really simple ... I'm just not very familiar with the text functions. :

Grant

Link to comment
Share on other sites

You will not have this problem if you include the separators in the string (see how SlimJim's formula wraps both strings in carriage returns). So instead of looking for "test" in "test¶testimony", you will be looking for "¶test¶" in "¶test¶testimony¶".

Link to comment
Share on other sites

thanks for the explanation!

I've implemented Slim Jim's calc and it does the job ... except it leaves a load of ¶ characters in the field once it has finished.

I'm surprised though, that there isn't any kind of replace function that will work on 'words' instead of text strings. Every word processor can do this.

Couldn't I use the Exact function in some way, to replace the words? And then just replace any ¶¶ with a later substitution?

Grant

Link to comment
Share on other sites

it leaves a load of ¶ characters in the field

No it doesn't - you must have made some mistake in your implementation.

Every word processor can do this.

Yes - but Filemaker is not a word processor. A word processor is meant to be used by USERS, with no further development. Filemaker, OTOH, does virtually nothing out of the box. You need to DEVELOP a solution, before it can be used. If you so choose, you can include such functionality.

Link to comment
Share on other sites

No it doesn't - you must have made some mistake in your implementation.

Okay ... I'll check it through. :

You need to DEVELOP a solution, before it can be used. If you so choose, you can include such functionality.

Hmmm ... yup, that's fair comment ... ehhh comment.

Thanks for your help and ... merry Christmas!,

Grant

Link to comment
Share on other sites

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