Jump to content

Using Position, separate ";"


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

Recommended Posts

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.

Link to comment
Share on other sites

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 )
Link to comment
Share on other sites

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 )
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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 ).

Link to comment
Share on other sites

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. :(

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Are there really spaces after every semi-colon? I would do it slightly differently:

 

Trim( getValue( substitute( yourString; ";" ; "¶");1))

  • Like 1
Link to comment
Share on other sites

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:)

 

Link to comment
Share on other sites

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