We have updated our Terms of Service, Code of Conduct, and Addendum.

Is there a simple way to do if-elif-elif in an eval statement? Support 3 or 4 tests

Options
Tony Reinke - Cribl
Tony Reinke - Cribl Posts: 134 admin
edited September 2023 in Stream

Support 3 or 4 tests

Best Answers

  • David Maislin
    David Maislin Posts: 228 mod
    edited September 2023 Answer ✓
    Options

    There are a couple simple approaches using the Lookup Function or the Eval Function that should be easy to understand and maintain.

    IN:


    Example 1: The Lookup Function

    Under Knowledge Lookups, create a Lookup Table

    Add a Lookup Function (Advanced Settings Ignore Case)


    Example 2: The Eval Function

    The syntax of /^IN$/i.test(direction) is a case insensitive (i) regular expression that tests for a match in the field direction. The ^ and $ represent the beginning and end of the value. The first line of the evan ensures that a direction field is not created if direction is not defined.


  • David Maislin
    David Maislin Posts: 228 mod
    Answer ✓
    Options

Answers

  • David Maislin
    David Maislin Posts: 228 mod
    edited September 2023 Answer ✓
    Options

    There are a couple simple approaches using the Lookup Function or the Eval Function that should be easy to understand and maintain.

    IN:


    Example 1: The Lookup Function

    Under Knowledge Lookups, create a Lookup Table

    Add a Lookup Function (Advanced Settings Ignore Case)


    Example 2: The Eval Function

    The syntax of /^IN$/i.test(direction) is a case insensitive (i) regular expression that tests for a match in the field direction. The ^ and $ represent the beginning and end of the value. The first line of the evan ensures that a direction field is not created if direction is not defined.


  • David Maislin
    David Maislin Posts: 228 mod
    Answer ✓
    Options