hartmut Posted April 13, 2008 Posted April 13, 2008 (edited) I would like to get a formula to find the entire last line of a paragraph. ( I mean the very last sentence of the entire field ) AND [color:red]I would like to find the very next [color:red]word to a [color:green]specific [color:yellow]word in a paragraph. In the last sentence , for example: find the word , immediately to the right of the word 'specific" which would be "in" I need to be able to do both these things with text in a field named "alltext" Thanks Dave Edited April 13, 2008 by Guest
comment Posted April 13, 2008 Posted April 13, 2008 I am not sure what you mean by "line of a paragraph". Filemaker doesn't know about "soft-returns" - these are created dynamically when a layout is rendered, and they don't really exist in the field data or anywhere else. The only separators you can use are the ones you have put in yourself. I would like to find the very next word to a specific word in a paragraph. In the last sentence , for example: find the word , immediately to the right of the word 'word" which would be "in" Or "to". Clarify.
comment Posted April 13, 2008 Posted April 13, 2008 I'm afraid we're not making much progress here. So you have replaced "line" with "sentence" - but what defines a sentence? How would a computer - that doesn't understand the text contents - know where a sentence starts and where it ends? It's too bad you have changed your first example, too. Because the question still stands: if the specified word occurs more than once in the examined text - which occurrence do you want? Removing the problem from the example doesn't make it go away.
hartmut Posted April 14, 2008 Author Posted April 14, 2008 Ok Lets say I have a text field called. "ALL" in it is the following the dish ran away with the spoon Fe Fi Fo Fum [color:red]http://www.apple.com I would like to make a script to automatically copy the last line The one in red. It usually begins with "http" but I would like to get the rest of the line. or [color:red]http://www.apple.com
mr_vodka Posted April 14, 2008 Posted April 14, 2008 Well you can use a position () to figure out where the position of a particular string exists. In your case you may be able to use RightValues ( YourText ; 1 ) however, it does seem that things still remain a little unclear.
Lee Smith Posted April 14, 2008 Posted April 14, 2008 (edited) As Mr V stated, it seems that you are unclear as to the how the text will be. You stated that [color:blue] It usually begins with "http", if it is always, or you can live with usually, than you could use one of comments calculations. I have modified this one, and it seems to work. Let ( len = Length ( YourTextField YourTextField ) ; Right ( YourTextField ; len - Position ( YourTextField ; "http://"; len ; -1 ) +1) ) HTH Lee Edited April 14, 2008 by Guest
hartmut Posted April 14, 2008 Author Posted April 14, 2008 (edited) Thank you It works perfectly I don't really understand it. I wish I did. I took out one "your textfield."then it worked great. I want to experiment with this more.Then I will ask you more about it. One question leads to another in my understanding. Actually I have one. This is almost the same as the one that you answered with a twist. Lets say my text field "all" has another constant like the word "colors" and the text field is formatted so the very next line (carriage return) of colors is what i am trying to extract. Can this be done in a similar way? ex. colors brown, green , yellow ex another example might be colors red So the calc would have to find "colors" and then extract the entire next line. I would like to learn how to do this variation Thanks very much Dave Edited April 14, 2008 by Guest
mr_vodka Posted April 14, 2008 Posted April 14, 2008 There are many different ways to try and parse this info out. I would suggest that you just play with the Text functions such as Left (), Right (), Middle (), Position (), LeftValues (), Length (), MiddleValues (), RightValues (), GetValue (), ValueCount (), etc. to get a better feel for it.
Lee Smith Posted April 14, 2008 Posted April 14, 2008 len = Length ( YourTextField YourTextField ) Oops, typo. Lee
hartmut Posted April 14, 2008 Author Posted April 14, 2008 Thanks lee I appreciate it. If you have any input on my last request - it is another facet of what I am trying to do and don't know how to do.
comment Posted April 14, 2008 Posted April 14, 2008 Start by finding the string "colors¶" in the text, using the Position() function. Assuming there will be only one occurrence of this string in the text: pos = Position ( text ; "colors¶"; 1 ; 1 ) Add 7 (the length of "colors¶") to get the starting point of actual colors: start = pos + 7 Now, to find the end we look for the first carriage return after start (if there is one, so to make sure we'll append one to the text): end = Position ( text & ¶ ; ¶ ; start ; 1 ) Now you have what you need to use the Middle() function in order to extract the colors: Middle ( text ; start ; end - start )
Lee Smith Posted April 14, 2008 Posted April 14, 2008 (edited) I agree with Mr. Vodka. and Listen to what comment says. Start by studying the examples of the different functions that he mentioned, and make yourself an example file for each so that you can what they do. There isn't, or least there wasn't for me, a quick way to learn these. You should also do a search of the Forum for [color:blue]+Parse +Text +Field or [color:blue]+Extract +Text +Field, and you should find a lot of treads on this need. Read what the Original Poster (OP) has requested as a need, and then the responses. I would put the sample text into a field, and test the different responses to see what they are actually doing. There isn't any one calculation, or function that will cover all needs. It usually isn't as simple as Right (or Left) one character, or word, and will usually require a combination of functions. HTH Lee Edited April 14, 2008 by Guest
hartmut Posted April 15, 2008 Author Posted April 15, 2008 I tried to do that. But I don't know exactly how to put it into a calculation. I used what you said pos = Position (Color::all ; "Colors¶"; 1 ; 1 ) & start = pos + 4 & end = Position ( Color::all ; start ; 1 ) & Middle ( Color::all ; start ; end - start ) I try to put it into a calculation and it says "pos" is an unknown field. I am not sure how to do this Thanks Dave
comment Posted April 15, 2008 Posted April 15, 2008 (edited) Either use the Let() function to define the intermediate variables, or replace them entirely by their formulae, going backwards, e.g. Middle ( Color::all ; start ; end - start ) becomes: Middle ( Color::all ; start ; Position ( Color::all & ¶ ; ¶ ; start ; 1 ) - start ) and so on. Hint: using the Let() function is a LOT easier - read the help on how to use it properly. EDIT I used what you said pos = Position (Color::all ; "Colors¶"; 1 ; 1 ) [color:red]& start = pos + [color:red]4 [color:red]& end = Position ( Color::all [color:blue]& ¶ ; [color:blue] ; start ; 1 ) [color:red]& Middle ( Color::all ; start ; end - start ) That is NOT what I said - see corrections in colors. Computers are unforgiving beasts. Edited April 15, 2008 by Guest
hartmut Posted April 17, 2008 Author Posted April 17, 2008 I am just not getting this I am going to start again. Lets say my text field "all" has another constant like the word "colors" and the text field is formatted so the very next line (carriage return) of colors is what i am trying to extract. Can this be done in a similar way? example 1 colors brown, green , yellow yields brown, green , yellow example 2 colors red Yields red example 3 colors red, green, yellow, purple yields red, green, yellow purple So the calc would have to find "colors" and then extract the entire next line. I would like to learn how to do this variation
mr_vodka Posted April 18, 2008 Posted April 18, 2008 I dont know what else to say... Michael had already posted the technique to do it. What I recommend that you should do is think about the logic before the actual syntax. That is why I recommended you PLAY with those text functions. Try it on simple paragraphs and see what is returned. HINT: Basically here is how it works... You said that you want the next line AFTER "colors". So that means that you will have to search for the string "colors" and the carriage return ¶ (pilcrow).... P.S. BTW, keep in mind as a reminder that this works only if there is one instance of "colors¶" as already pointed out earlier
Lee Smith Posted April 18, 2008 Posted April 18, 2008 Hi Mr. V. Your reply is very close to what I was going to reply with. I will only add for the benefit of hartmut, that unless you are strong in math, this is not something that you can expect to learn with a simple lesson. You really have to do your home work. Mr V did say this too, but it is important to know, so I'll repeat it. In FileMaker, the Pilcrow (i.e. ¶ ) = a carriage return. Lee
hartmut Posted April 18, 2008 Author Posted April 18, 2008 Whatever was posted didn't work for me; I don't understand the let function. I try things and they don't work. It is really messing me up
Lee Smith Posted April 18, 2008 Posted April 18, 2008 (edited) Maybe if you see them in action. Here is a simple demo file HTH Lee [color:red]p.s. [color:blue]I uploaded a file i had played with, here is the one that applies. LetBrokenDown.fp7.zip Edited April 18, 2008 by Guest
hartmut Posted April 18, 2008 Author Posted April 18, 2008 thank you so much. I have already made 3 uses of it. So I can study it for a while Seeing it work got me past my problem. There is one problem though sometimes in my situation i get an underscore like red_orange and it just picks up the orange. Why doesn't the underscore make up part of the word? And is there a way to get it to work with an underscore or hyphen in a text calc.?
Lee Smith Posted April 18, 2008 Posted April 18, 2008 Are you saying that you want to preserve the underscore, or eliminate it? I pasted in red_orange, and the calculation left it in. If you want to take it out and replace it with a space, you can do that by adding a substitute Function. Let ( [ pos = Position ( Text ; "colors¶" ; 1 ; 1 ) ; start = pos +7; end = Position ( Text & ¶; ¶ ; start ; 1 ) ] ; Substitute( Middle ( Text ; start ; end - start ) ; "_" ; " ") ) Lee
Recommended Posts
This topic is 6409 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 accountSign in
Already have an account? Sign in here.
Sign In Now