Brian Dunning's FileMaker Custom Functions

NumberList ( start ; end ; increment )

Returns a list of numbers from 'start' to 'end', incremented by 'increment'

  Average rating: 4.3 (35 votes) Log in to vote

Gordon Kilgour   Gordon Kilgour
n/a
n/a

Share on Facebook Share on Twitter

  Sample input:
NumberList ( 2 ; 5 ; 0.5 )
  Sample output:
2
2.5
3
3.5
4
4.5
5

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

Returns a carriage-return separated list of the numbers from 'start' to 'end' inclusive, incremented by the 'increment' value. Good for a Pop-up Menu or Drop-down List to limit user entry to specific values.

For example, for all even numbers from 2 to 8,
NumberList ( 2 ; 8 ; 2 ) would return:-
2
4
6
8

For all tens from 50 to 100,
NumberList ( 50 ; 100 ; 10 ) would return:-
50
60
70
80
90
100

 

Comments

Marc Wood   Marc Wood, Minneapolis MN
Sep 21, 2010
Doesn't work if you want to count backwards (decrement), but if you *only* want to count backwards, you can change "start < end" to "start > end" and "start + increment" to "start - increment" -- then NumberList ( 3 ; -2 ; 1 ) will yield:
3
2
1
0
-1
-2
 
Gordon Kilgour   Gordon Kilgour, Edinburgh
Sep 22, 2010
It's a useful addition Marc, thanks.
 
Marc Wood   Marc Wood, Minneapolis MN
Sep 22, 2010
Thank *you* -- I used it to generate the X-axis in a FileMaker charting script.
 
Vaughan   Vaughan, Sydney, Australia
Jul 28, 2011
It hits the 10,000 recursion limit:

NumberList( 0 ; 10000 ; 1 ) = ?
 
Gordon Kilgour   Gordon Kilgour, Edinburgh
May 15, 2012
That is true Vaughan but for practical purposes it's irrelevant. It would also be very simple to add a check for this.
 
Dan Shockley   Dan Shockley, New York, NY
Aug 26, 2014
Useful!
I added some things that let you increment/decrement by picking a positive/negative 'changeBy' parameter. Note that if changeBy is negative, then your rangeStart must be greater than rangeEnd.

// ValueNumbersFromRange ( rangeStart; rangeEnd; changeBy )
// version 1.0, Daniel A. Shockley, inspired by Gordon Kilgour's NumberList, http://www.briandunning.com/cf/1172

// Generate a return-delimited list of numbers for the specified range by the specified increment.

/* VERSION HISTORY:
1.0 - intitial version.
*/


Case (

changeBy = 0 /* ERROR */
; "?"
;
changeBy > 0 and rangeStart > rangeEnd /* ERROR */
; "?"
;
changeBy < 0 and rangeStart < rangeEnd /* ERROR */
; "?"
;
rangeStart = rangeEnd
; rangeStart
;
List ( rangeStart; ValueNumbersFromRange ( rangeStart + changeBy; rangeEnd; changeBy ) )
)
 
Dan Shockley   Dan Shockley, New York, NY
Aug 27, 2014
Actually, don't return "?" if the rangeEnd/rangeStart seem wrong, since you might be going from 2 to 7 incrementing by 2 and don't want to get 2¶4¶6¶?
Instead, just return "" when that happens so you would get, in this example, 2¶4¶6

Updated calc:
// ValueNumbersFromRange ( rangeStart; rangeEnd; changeBy )
// version 1.0, Daniel A. Shockley, inspired by Gordon Kilgour's NumberList, http://www.briandunning.com/cf/1172

// Generate a return-delimited list of numbers for the specified range by the specified increment.

/* VERSION HISTORY:
1.0 - intitial version.
*/


Case (

changeBy = 0 /* ERROR */
; "?"
;
changeBy > 0 and rangeStart > rangeEnd /* Finished */
; ""
;
changeBy < 0 and rangeStart < rangeEnd /* Finished */
; ""
;
rangeStart = rangeEnd
; rangeStart
;
List ( rangeStart; ValueNumbersFromRange ( rangeStart + changeBy; rangeEnd; changeBy ) )
)
 

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Under construction. Email me your wish list for improvements.