Share

Creating sequences

Use the make_sequence and next_in_sequence functions to create sequences. Sequences contain:

  • a starting value. This defines the first element in the sequence.

  • an incremental value. This returns the next element in the sequence.

  • an optional padding value. This adds extra zeros before the returned elements .

To create a new sequence, use the make_sequence function. The basic structure is:

OBJECT make_sequence( int start_value, [, int increment, int padding])

For example:

OBJECT seq = make_sequence(10, 5, 4)
//Returns a sequence which starts at 10, increments by 5 and is padded by 4 characters:

To increment a value in a specified sequence, use the next_in_sequence function. The basic structure is:

string next_in_sequence(object sequence)

For example:

OBJECT seq = make_sequence(10, 5, 4)  
// Makes a new sequence starting from 10, incremented by 5 and padded to 4 characters  
STRING n = next_in_sequence(seq)  
// n = "0010"  
STRING nn = next_in_sequence(seq)  
// nn = "0015"  
STRING nnn = next_in_sequence(seq)  
// nnn = "0020"

Was this information helpful?