LAE

Welcome to the LAE community!  Please feel free to start a discussion in the discussion tab or join in a conversation.

Discussions

Members

Resources

Events

 View Only
  • 1.  How to replace the value of a specific field in output

    Employee
    Posted 06-29-2011 03:04

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: Papazol

    Hi,
    I try to output some records and at the same time replace/modify a field that match the expression:

    if (regexIsMatch(Bnr_P,"322412..112"))then {Bnr_P = "32212"} else Bnr_P
    emit Anr_P,Bnr_P,CallStartdate_P,Duration_P,Intrunk_P,Outtrunk_P,TypeOfAnr_P,TypeOfBnr_P
    The output contents the Bnr_P matching the expression as 32212 and all other Bnr_P as NULL.


    Solution:
    BNR_2=if (regexIsMatch(Bnr_P,"322412..112"))then {"32212"} else Bnr_P emit Anr_P,Bnr_P=BNR_2,CallStartdate_P,Duration_P,Intrunk_P,Outtrunk_P,TypeOfAnr_P,TypeOfBnr_P


  • 2.  RE: How to replace the value of a specific field in output

    Employee
    Posted 06-29-2011 05:02

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: stonysmith

    Originally posted by: Papazol
    					

    if (regexIsMatch(Bnr_P,"322412..112"))then {Bnr_P = "32212"} else Bnr_P
    In your first statement, there is a syntax problem that is not caught by the system.

    effectively, you have:

    if test then A=1 else A
    and instead you need one of these two:

    if test then A=1 else A=2
    or as you did:
    A= if test then 1 else 2
    ====================
    The IF operator in LAE is not quite the same as in other languages.. it can can be either a statement or a value. Your first attempt was mixing the two forms. Your solution that worked is using the IF as an operator that returns a value. Either way, you shouldn't mix the two forms.