Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

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

Recommended Posts

Posted

Has anyone seen a calc or custom function for converting a number range into a return separated list?

1-4 =

1

2

3

4

Posted

...custom function for converting a number range into a return separated list?

What about this one ?

Range ( values )

Let([

sep = Filter ( values ; " -/|_*to" ) ;

start = GetAsNumber ( GetValue ( Substitute ( values ; sep ; ¶ ) ; 1 ) ) ;

stop = GetAsNumber ( GetValue ( Substitute ( values ; sep ; ¶ ) ; 2 ) )

];

Case(

stop - start ≥ 10000; "error" ;

start < stop ; start & ¶ & Range ( start + 1 & ¶ & stop );

start = stop ; stop

)

)

Note: values can be proposed in various ways, like:

1 to 4

1 4

1-4 ; 1 - 4

1/4 ; 1 / 4

14 ; 1 4

1|4 ; 1 | 4

1_4 ; 1 _ 4

1*4 ; 1 * 4

but must be both positive.

So this: Range ( "20 to 25" ) gives:

20

21

22

23

24

25

The CF can't handle range of more than 9999 values.

Posted

Thanks guys this works really well. Now can I take it one step further.

I would like the user to be able to type a range as well as individual numbers.

2-6, 8,11, 22-26

I need a CF:

1. return separate the list (sub "," ; "¶")

2-6

8

11

22-26

2. run through the list. I would assume 'MiddleValue'

3. if value contains "-" use 'EnumerateRange' else append to result

Recursive eludes me, any help is appreciated.

Posted

Thanks Comment, that is exactly it.

As for entry I agree with you, but this is for printing pages so it is temporary data.

Thanks Again!

Posted

hi Comment,

the left and right words had to be converted to numbers to work properly, I found this out when I tried "5-18"

-=-=-=-=-=-=-

MultiEnumerate

Let ( [

values = Substitute ( input ; [ "," ; ¶ ] ; [ "-" ; " " ] ) ;

countValues = ValueCount ( values ) ;

this = GetValue ( values ; 1 )

] ;

Case ( WordCount ( this ) > 1 ; Enumerate ( GetAsNumber ( LeftWords ( this ; 1 ) ) ; GetAsNumber ( RightWords ( this; 1 ) ) ) ; Trim ( this ) )

&

Case ( countValues > 1 ; ¶ & MultiEnumerate ( RightValues ( values ; countValues - 1 ) ) )

)

//MultiEnumerate ( input )

-=-=-=-=-=

Posted

Actually, the fault is with the Enumerate () function, you should make the change there:


start & Case ( GetAsNumber (start) < GetAsNumber (end) ; ¶ & Enumerate ( start + 1 ; end ) )

Originally, when I wrote the Enumerate() function, the possibility of parameters being text never came up.

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