chuckcou Posted March 31, 2016 Posted March 31, 2016 I have a field string->Dog; Cat; Horse; Frog; People I am trying to make a calculation field that will put the value within separate fields. So I got the 1st one--Left(field;Position(field;";";1;1)-1) This works to get the word Dog. But my next calculation field is not working- Left(field;Position(field;";";1;2)-1) Of course I did not get to Third, 4th, 5th. what am I doing wrong? Can someone enlighten me.
Lee Smith Posted March 31, 2016 Posted March 31, 2016 Why the duplicate post? I delete the other two. Please give us an actual example of the text.
Josh Ormond Posted March 31, 2016 Posted March 31, 2016 It may be easier to flip the string. Then use GetValue ( ) to pull out the value you need. Easy if the text string is well formatted. GetValue ( Substitute ( stringText ; "; " ; ¶ ) ; 1 ) GetValue ( Substitue ( stringText ; "; " ; ¶ ) ; 2 )
Josh Ormond Posted March 31, 2016 Posted March 31, 2016 It may be easier to flip the string. Then use GetValue ( ) to pull out the value you need. Easy if the text string is well formatted. GetValue ( Substitute ( stringText ; "; " ; ¶ ) ; 1 ) GetValue ( Substitue ( stringText ; "; " ; ¶ ) ; 2 )
chuckcou Posted March 31, 2016 Author Posted March 31, 2016 Sorry Lee. When submitting the system hung. So after about a minute I hit Submit again. Waited two minutes-Nothing. did a refresh then it took it the third time after about 30 seconds. Not sure the reason for the delay. But the Double post is probably from me hitting Submit twice.
Josh Ormond Posted March 31, 2016 Posted March 31, 2016 You are fine @chuckcou. It looks like it was a temporary glitch.
chuckcou Posted March 31, 2016 Author Posted March 31, 2016 Hmm that not working very well. If I have a field(call it List) with it value being "Cat; Dog; Horse; Pig" What calculation would I use to get Dog? What calculation would I use to get Horse? What calculation would I use to get Pig? If this were php I would just separate each at the ";" , and put into an array. Lastly then call the array. File Maker is a little different for sure.
Josh Ormond Posted March 31, 2016 Posted March 31, 2016 Substitute ( List ; "; " ; ¶ ) will convert "Cat; Dog; Horse; Pig" to: Cat Dog Horse Pig GetValue ( text ; value ) tells FM to pick the value in the supplied list. Each line in the list is a 'value' to FM. GetValue ( Substitute ( List ; "; " ; ¶ ) ; 1 ) will return Cat ( the 1st value in the list ). GetValue ( Substitute ( List ; "; " ; ¶ ; 2 ) will return Dog ( the 2nd value in the list ).
Lee Smith Posted March 31, 2016 Posted March 31, 2016 Hey Chuck, Refreshing the page is a good way to do it, I’ve had to do it a couple of times today too. I have sent a message to Ocean Wests, I think that the site needs to be restarted. I’m not going to delete any duplicates yet, I want OW to see them first. Lee wow, I thought this went out 45 minutes ago.
chuckcou Posted March 31, 2016 Author Posted March 31, 2016 Thanks Lee for the update. Josh I must have type something wrong let me try again.
Lee Smith Posted March 31, 2016 Posted March 31, 2016 Chuck, Let’s use actual text, and not generic text. The reason is you then can adapt it to your solution quicker and sometimes the text will lead to clues in how we suggest you extract or parse it out.
bruceR Posted March 31, 2016 Posted March 31, 2016 Are there really spaces after every semi-colon? I would do it slightly differently: Trim( getValue( substitute( yourString; ";" ; "¶");1)) 1
chuckcou Posted March 31, 2016 Author Posted March 31, 2016 Thanks all Bruce, Lee, Josh. Perfect Trim( getValue( substitute( yourString; ";" ; "¶");1)) I had misspelled by field number when I replaced the your String above. All is working correctly now and is exactly what I was looking for. get Value was much easier. I will have to do some homework on getValue. Thanks again
Josh Ormond Posted April 1, 2016 Posted April 1, 2016 Great. Glad it's working. @BruceR Thank you. That is definitely a better approach. In practice that is how I would normally approach it.
Recommended Posts
This topic is 3424 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