PiedPiper Posted January 8, 2004 Posted January 8, 2004 ok. I'm tired of messin with this stuff. I don't understand when I can inside calculatons, replace a 'field surrounded by a different function' for a field requirement. please help me understand how it works. Ive been trying to understand this one for three days. It's the last thing I need to do to split some data and I just don't understand it. It seems so simple. I have a field (FIELD) text which looks like: LSSHMAILING11212002 I need to remove the first four letters from the left and just leave the rest of the field okay. The first four letters will all be different. I thought ok start from position 5 from the left and take everything to the right of that so I figured I'd need: Left ( text , number ) and inside that in place of the text, identify the 'changed field' (changed by the position starting at 5) and where to start and how much should be huge like 999 (I read that) So I pasted the above in the box and right below that placed position. Position ( text , search
John Caballero Posted January 8, 2004 Posted January 8, 2004 How about this... Create a text calculated field, cText: Right(FIELD, Length(FIELD)-4) Using your example the result is "MAILING11212002". Is that what you're after?
Fenton Posted January 8, 2004 Posted January 8, 2004 Middle (text, start, size) Middle(Field, 5, 999) Or Right(Field, Length(Field) - 4) You were attacking from the wrong side basically. Also, when you say Position (Field, Field, 5, 1). You can't look for the entire field in itself, but start at the 5th position. What is being looked for has to be after the start position, or you got nothin.
RodinBangkok Posted January 8, 2004 Posted January 8, 2004 Or how about Middle(Field,5,Length(field), just in case the size of the field is unknown. Or perhaps Replace (field, Left (field, 1), 4, "").....just some more examples of probably many ways to get the job done. Rod
PiedPiper Posted January 9, 2004 Author Posted January 9, 2004 Hey guys thanks! John, Right(FIELD, Length(FIELD)-4) Yep it worked. Although I have no idea why. If coming at this from the right, Length -4 should give me the field -4 characters from the right
ESpringer Posted January 9, 2004 Posted January 9, 2004 Pete, Chapter 6 (on complex calcs) in Chris Kubica's _The Book of FileMaker 6_ looks OK as a tutorial... it's the only one I happen to have. The book comes with a CD of example files -- although taking apart some of the sample files available here would certainly be a good start to digesting what calcs can do...
John Caballero Posted January 9, 2004 Posted January 9, 2004 Hi Pete, The Right(field, n) function tells FileMaker to return n number of characters from the specified field content, starting from the right. If you have a field ("name") with the value of "John Caballero", Right(name, 1) will return "o". Right(name,5) = "llero" The Length(field) function returns the number of characters (including spaces and whatnot) in the specified field. Length(name) = 14. So Right(name, Length(name)-4) is the same thing as Right(name,10). If the length of my "name" field for every record was always 14 and would never change, then I could, and probably would, just use Right(name, 10)...but how often is it the case that the contents of a field are the same number of characters in every record of a database? Given that your field contents may not always be the same length, it's better to keep things as dynamic as possible - that's why Fenton and I both suggested Right(field, Length(field)-4). The only hard-coded variable is 4 which is the number of characters you said you needed to have stripped from the source field.
Recommended Posts
This topic is 7694 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