enum

enum, keyword

The enum keywork is used to introduce a complex data type.

table enum Countries = "BE", "FR", "UK", "US"

show table "Countries" a1b4 with
  text(Countries.Value)
  "(\{Countries.Label})"
 
be = enum.Countries("BE")
show scalar "Belgium" c1 with text(be)

enum(v: text) 🡒 enum _, function

The function enum creates an anonymous enum based on its input text vector. The input vector may include duplicates among the text values. A new overload for the function text is also created to convert back the enum values to text.

table Countries = with
  [| "BE" as Code |]
  [| "DE "|]
  [| "FR" |]
  [| "US" |]
  [| "BE" |] // duplicate

Countries.AnoEnum = enum(Countries.Code)

show table "Countries" a1b4 with text(Countries.AnoEnum)