Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

Posted

Hello, I have a number field where I want the user to be able to enter things like:

  • 42 (only item 42)
  • 12+82 (only items 12 and 82)
  • 1-5 (items 1 through 5)
  • 31,33,35,37 (only items 31,33,35,37)

So I am need of a way for filemaker to deal with the operators '+' '-' and ','

Do you have any advice on how I can separate out the item numbers?

Thanks!

Posted (edited)

Actually, you only need to "deal" with the "-" operator. The "+" and the comma can be simply substituted with a carriage return to get a list that Filemaker recognizes as a list of values (assuming that's what you want as the result).

Iterating from 1 to 5 and creating the intermediate values requires either a custom recursive function or the While() function or a looping script. Please update your profile to reflect your version and OS so that we know which one of these you can use.

--
Note:
1. A field where a user is allowed to enter "12+82" or "1-5" or "31,33,35,37" should be a Text field.
2. You may face a difficulty if a user enters a value that does not fit one of your 4 formats listed above.

 

Edited by comment
  • Like 1
Posted

Thanks so much for your help, I have updated my profile and started work on the + and , 

Posted

If you don't have the Advanced version, you cannot use a custom function (unless someone installs it for you). And if you don't have version 18,  you cannot use the While() function. That leaves us with a looping script. The attached demo shows how it could work.

Note that you can use a script trigger to run the script automatically OnObjectSave.

ProcessEntry.fmp12

  • Like 1
Posted (edited)

Thank you so much comment, your file is perfectly clear. The next hurdle I am working on is to allow the user to have both in the same list.

For example: 1-5,19+25,30-33

I believe I should turn the + and , into carriage returns first, then deal with the hyphens with a loop through the list entries somehow

Edited by nsdodgers
Posted (edited)
6 hours ago, nsdodgers said:

I believe I should turn the + and , into carriage returns first, then deal with the hyphens with a loop through the list entries somehow

I would start by substituting "+" and "," with ¶. Then loop over the resulting values. If the current value contains "-", create the intermediate values and add them to the result. Otherwise add the value to the result.

 

Edited by comment
  • Like 1
  • 2 weeks later...
Posted (edited)

It's the reverse of what we worked on in the other post. Going from a list to a range

Edited by nsdodgers

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