svvs(X;Y;Z;I;B)

Decode and then encode a value based on an index.

Syntax

svvs(X;Y;Z;I;B)

Input

Argument Type Description
X integer The value to decode

A scalar value or the name of a column

Y integer A number or set of numbers to use a bases for the output

For example, if the parsed digits are 1 2 3 4 and Y is 10 10 10 10, the output is displayed as four base-10 digits: 1234.

Z integer The number or set of numbers to add to the parsed digits

For example, if the parsed digits are 1 2 3 4, Y is 10 10 10 10, and Z is 2, the output is displayed as 3456.

I integer The index (order) of the parsed digits

The examples below show how I orders the parsed digits 1 2 3.

  • If I is 0 1 2 the three digits remain in the same order: 1 2 3.
  • If I is 2 1 0, the three digits are displayed in reverse order: 3 2 1.
  • If I is 2, the digits are displayed for index position 2 only: 3
B integer A number or set of numbers to use as bases to decompose the input digits.

The number X is split apart into "digits" according to these values. For example, if X is 20190905 and B is 0 100 100, X is split into 3 parts, including two base-100 digits, and then the leftover digits, as follows: 2019 09 05.

Return Value

Returns a single output number of the transformed number X.

Sample Usage

scalar value bases for output add index bases for input svvs(scalar value;bases for output;add;index;bases for input)
19991231 100 0 2 0 100 100 31
  • Split up number into 1999 12 31
  • Add 0
  • Display the number at index position 2
  • Display the number in base 100
19991231 100 100 0 0 1 0 100 100 199912
  • Split up number into 1999 12 31
  • Add 0
  • Display the numbers at index position 0 and 1
  • Display the number in base 100
235959 24 60 60 0 0 1 2 100 100 100 86399 (the number of seconds in 23:59:59)
  • Split up number into 23 59 59
  • Add 0
  • Display all three numbers in the same order
  • Convert the hours to base 24, convert the minutes to base 60 and convert the seconds to base 60
1234 10 10 10 10 5 3 2 1 0 10 10 10 10 9876
  • Split up number into four single digits
  • Add 5 to each digit
  • Reverse the order of the single digits

Example

This example demonstrates how svvs(X;Y;Z;I;B) can parse a YYYYMMDD date into month, day, and year.

<base table="pub.demo.retail.item"/>
<willbe name="month" value="svvs(date;100;0;1;0 100 100)"/>
<willbe name="day" value="svvs(date;100;0;2;0 100 100)"/>
<willbe name="year" value="svvs(date;100;0;0;0 100 100)" format="type:nocommas"/>
<colord cols="date,month,day,year"/>