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

Recommended Posts

Posted

Could a text calculation be written to remove the LN3615 and the following single character space from the below field to leave 'Helpston Jn to Syston South Jn'. It would be ideal if the calculation could remove all characters up to and including the first space as sometimes the code could be five or six characters.

LN3615 Helpston Jn to Syston South Jn

BTW I am aware that is it the fact that I have two items in one field that is making this calculation necessary. It's an inherited file and I thought it would be interesting to see the calculation.

Posted

Assuming the code is always a single word, you could use RightWords() to extract the remaining text. Otherwise use Position() to find the position of the first space, and Right() to return the following text.

Posted

Assuming the code is always a single word, you could use RightWords() to extract the remaining text. Otherwise use Position() to find the position of the first space, and Right() to return the following text.

Thanks Comment. Would that be something like this:

Right(Position(Section;" ";1;1)-1)

Length() doesn't need to be part of this calculation does it?

Posted

RightWords (your field ; 6 ) //if the pattern is always 7 words

Length() doesn't need to be part of this calculation does it?

Does this mean that the pattern can have more than 7 words?

Posted

Length() doesn't need to be part of this calculation does it?

Yes, it does.You need to subtract the position of the first space from the overall length in order to get the number of characters you need, counting from the right.

Posted

RightWords (your field ; 6 ) //if the pattern is always 7 words

Does this mean that the pattern can have more than 7 words?

Hi Lee, yes the pattern can have more than 7 words.

Yes, it does.You need to subtract the position of the first space from the overall length in order to get the number of characters you need, counting from the right.

I'll try and get that into a calculation then :unsure:

Posted


Let (

pos = Position ( text ; " " ; 1 ; 1 ) ;

Right ( text ; Length ( text ) - pos )

)

Added ... I wouldn't use xWords for things such as this unless you can guarantee that the first character will never be $, #@& ... or any other 'word break' characters. xWords can lose characters that a human considers to be part of the word. :logik:

Posted

Thanks LaRetta, I've just learned something else from the way you have written the calculation. It seems that the three steps have been separated onto different lines for ease of understanding. I need to study calculations, particularly when they are encompassed by other calculations. I beleive they are evaluated from the inside out.

Posted (edited)

I beleive they are evaluated from the inside out.

And that is how you create them ... from the original data backwards (outwards), wrapping with the next function to take the result of the last function and apply the next function until the last step (the most outward) will be the result that you want. There are additional rules of precedence which influence the order of operations called PEMDAS meaning parenthesis, exponent, multiplication, division, addition and subtraction.

Let() is the most beautiful function in FileMaker. Period. It allows us to list our thinking clearly (sometimes I use it only for clarity when read by myself later or others, sometimes I use it for clarity as I'm writing a calc; as a chalkboard and test/adjust as I go. Of course Let() especially saves evaluations if the thing being evaluated must happen more than once, and more.

Edited by LaRetta
Posted

Let() is the most beautiful function in FileMaker. Period. It allows us to list our thinking clearly (sometimes I use it only for clarity when read by myself later or others, sometimes I use it for clarity as I'm writing a calc; as a chalkboard and test/adjust as I go. Of course Let() especially saves evaluations if the thing being evaluated must happen more than once, and more.

I was actually expecting the outermost calculation to be Right(). Thanks for explaining the Let() function.

Posted

Right() IS the calculation of the Let() function ...

Let (

pos = Position ( text ; " " ; 1 ; 1 ) ;

Right ( text ; Length ( text ) - pos )

)

... and it could work just as well, written as:

Right ( text ; Length ( text ) - Position ( text ; " " ; 1 ; 1 ) )

... you almost had it and I should have gone your direction (using the second calc) so you can see it. I instead used Let() to show it more clearly but it isn't needed here since every evaluation only happens once. I guess if I had used the second calc then you wouldn't have learned about Let() today, LOL. :jester:

  • Like 1
Posted

Hi LaRetta,

:goodpost::exactly:

I guess if I had used the second calc then you wouldn't have learned about Let() today

I love it when we show them alternatives, after all, we are here to teach as well as learn.

Lee

Posted

I guess if I had used the second calc then you wouldn't have learned about Let() today, LOL. :jester:

Just to finish this off, we've established that we didn't need the Let() function in my scenario. Is there anything that Let() does specifically that no other function does?

Posted

You can read up on it in FM Help. Let() allow specifying variables which allows for clarity and efficiency because calculations can be declared once in a variable and then the variable can be used throughout. Let() can even be used within Let() allowing complex calculations to be written.

Posted

Is there anything that Let() does specifically that no other function does?

I believe there is only one: declare variables. Note that it can declare a variable of any one of the three types (var, $var or $$var).

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