nsdodgers Posted September 17, 2019 Posted September 17, 2019 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!
comment Posted September 17, 2019 Posted September 17, 2019 (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 September 17, 2019 by comment 1
nsdodgers Posted September 17, 2019 Author Posted September 17, 2019 Thanks so much for your help, I have updated my profile and started work on the + and ,
comment Posted September 17, 2019 Posted September 17, 2019 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 1
nsdodgers Posted September 17, 2019 Author Posted September 17, 2019 (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 September 17, 2019 by nsdodgers
comment Posted September 18, 2019 Posted September 18, 2019 (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 September 18, 2019 by comment 1
nsdodgers Posted September 27, 2019 Author Posted September 27, 2019 (edited) It's the reverse of what we worked on in the other post. Going from a list to a range Edited September 27, 2019 by nsdodgers
Recommended Posts
This topic is 2149 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