mkuid

mkuid, special function

def special mkuid(a: _typ): number
def special mkuid(a: _typ, offset: number): number

Returns a unique number, with uniqueness maintained across Envision runs. This function is intended to uniquely identify results calculated by Lokad (for example, purchase order numbers that increment on each run).

The vector a is ignored, but the UID is generated as a scalar in the table of a. The optional offset represents the starting suffix for the UID.

The generated numbers have the format PPPPPPPAAA, where:

Properties

  1. All UIDs can be parsed as numbers, and those numbers are different. UIDs have at least 10 digits, and can have more when more than 1000 are generated.
  2. A UID generated at time T is strictly inferior (lexicographic order) to a UID generated at time T' > T.
  3. If all calls generate a similar number of UIDs (less than 999, or between 1000 and 9999, etc.), then the previous property also holds for numeric order.

Example

table T = with
  [| as Word |]
  [| "The" |]
  [| "quick" |]
  [| "brown" |]
  [| "fox" |]
  [| "jumps" |]

show table "Unique identifiers" with
  mkuid(T.Word, 123) as "Uid"
  T.Word

This outputs the following table:

Uid Word
1001000123 The
1001000124 quick
1001000125 brown
1001000126 fox
1001000127 jumps
User Contributed Notes
0 notes + add a note