fail

fail, empty selection behavior

The keyword fail prevents Envision from replacing an empty selection by a default value.

It applies to lookups:

table T[x] = with
  [| as x, as Y |]
  [| "aa", 11   |]
  [| "bb", 12   |]
  [| "cc", 13   |]

a = T.Y["bb"] default fail

show scalar "" with a // displays 12

It applies to aggregators:

table T[x] = with
  [| as x, as Y |]
  [| "aa", 11   |]
  [| "bb", 12   |]
  [| "cc", 13   |]

T.C = same(x) 
  by T.Y at (min(T.Y + 1, 13))
  default fail

show table "" with x, T.C

It applies to processes:

table T[x] = with
  [| as x, as Y |]
  [| "aa", 11   |]
  [| "bb", 13   |]
  [| "cc", 12   |]

def process myMax(x : text) with
  keep mm = ""
  mm = max(x, mm)
  return mm

a = myMax(x) default fail sort T.Y

show scalar "" with a

fail, statement

The keywork fail leads a statement that includes a failure message.

def pure choose(c: boolean, x: number) with
  if c
    fail "My failed condition"
  else
    return x

The fail statements are only allowed within def pure and def process blocks.

User Contributed Notes
0 notes + add a note