# Need help with a script/function to strip integers from a selection in a value list.

Question asked by wheelman1138 on Jun 13, 2018
Latest reply on Jun 13, 2018 by beverly

Hi everyone! So the hurdle I'm trying to overcome is that I have a value list that contains width and height dimensions.

Sampling of that value list:

3.875 x 8.875

8.5 x 11

9 x 12

11 x 17

12 x 18

I'd like to set up a script trigger to pull each of the two integers out of the selected value and set them in Width and Height fields. The part I'm having a hard time figuring out is the "grabbing" of the appropriate number of characters (words?). I was going to just write a Case that says

If [ Table:Size_Choice = "8.5 x 11" ]

Set field [ Table:Width ; 8.5 ]

Set field [ Table:Height ; 11 ]

and then just repeat that for each choice.

However, that would mean if I added a value to that list, I would then need to go in and add a step to that script each time. I'm fairly certain there's a function that will strip the data I want from that value list, I'm just too much of a novice to know what it is or how it needs to be written to grab the correct data.

I think the function I want to use is the LeftWords. I've gotten that to work for the first number but then it grabs the first number, the "x", and the third number when I try to get just the second number. LeftWords ( Table:Size_Choice ; 3 ) is what is returning that undesirable result. I understand what is doing to return that data so my question is how do I get the just word in position 3? I think that's the answer I need.

Now you might say, use LeftWords to get the first number and RightWords to get the second number BUT

I have other places in my solution where I need to do this same thing but there is a one or two word description after the dimensions (i.e., 8.5 x 11 Tri-Fold). RightWords would return an undesirable result in cases like that. The only thing that is constant in all of the cases is that there is a number (with up to 3 decimals), a space, an x, a space, and a number (with up to 3 decimals) in all of the value lists.

Anyone out there want to give this one a bit of time? Thanks in advance!