Sequences and number systems
Generate runs of numbers, add up a polynomial, and move whole numbers between Roman numerals and any base from 2 to 36.
Syntax
Write the function's name and its arguments, anywhere a value is allowed, such as inside RETURN.
SEQUENCE(rows, [columns], [start], [step])
SERIESSUM(x, n, m, coefficients)
ROMAN(number, [form])
BASE(number, radix, [min_length])
DECIMAL(text, base)Parameters and arguments
Arguments are written in brackets, separated by commas. An argument in square brackets is optional.
SEQUENCE
Required: Yesrows
Required: Nocolumns
Required: Nostart
Required: NostepSERIESSUM
Required: Yesx
Required: Yesn
Required: Yesm
Required: YescoefficientsROMAN
Required: Yesnumber
Required: NoformBASE
Required: Yesnumber
Required: Yesradix
Required: Nomin_lengthDECIMAL
Required: Yestext
Required: Yesbase
Examples
A run of line numbers for an order, a grid of shelf positions, and pallet slots counted in tens from 100.
Return type and behaviour
Each function returns one value. The table shows its type, what it does and one way to write it; the examples use the functions in realistic statements.
| Function | Returns | Behaviour | Form |
|---|---|---|---|
SEQUENCE | list of rows | A grid of whole numbers filled row by row, each row a list | SEQUENCE(2, 3) |
SERIESSUM | decimal | The sum of each coefficient times x raised to its power | SERIESSUM(2.0, 0, 1, 1.0, 1.0, 1.0) |
ROMAN | text | The number as a Roman numeral | ROMAN(499) |
BASE | text | The number written in the base, with lower case letters for digits above 9 | BASE(255, 16) |
DECIMAL | whole number | The whole number the text stands for | DECIMAL("ff", 16) |
Errors and exceptions
| Error | What happened | How to recover |
|---|---|---|
HTQL-5001 | The function was given the wrong number of arguments. The message names the function and the counts | Give it the arguments listed under Parameters |
HTQL-1004 Unsupported function | The name is not a function this engine runs | Check the name and its spelling against this entry |
HTQL-2001 | ROMAN was given a number outside 1 to 3999 or a form outside 0 to 4 | Pass a value in range |
HTQL-2002 | BASE or DECIMAL was given a value outside its range, or text that is not a number in the base | Check the number, the base and the text |
Limitations
ROMANrefuses a number outside 1 to 3999 and a form outside 0 to 4 withHTQL-2001.BASErefuses a negative number, a base outside 2 to 36 and a minimum length outside 0 to 255 withHTQL-2002. Letters in the answer are lower case, soBASE(255, 16)isff.DECIMALneeds its first argument as text in quotes and its base as a whole number. Text that is not a number in that base is refused withHTQL-2002.SEQUENCEcounts in whole numbers, so a decimal start or step is cut to a whole number.SERIESSUMneeds at least four arguments, so at least one coefficient.
Permissions and security
These functions read nothing from your tables and write nothing.
When a function is applied to a column or a variable, the statement that reads the data needs read access, as its own entry says.
Best practices
- Use SEQUENCE to number lines, pallet slots or shelf positions instead of counting in your own code.
- Use BASE with a minimum length for fixed width codes, such as a label that is always four characters.
- Use SERIESSUM for a cost formula with a fixed part, a per unit part and a squared part, so the whole formula is one call.