IF statement Syntax

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf IF statement Syntax

  • Creator
    Topic
  • #53711
    Danny Wheeler
    Participant

      I am trying to write an IF statement to suppress all but a subset of messages.  Is this the correct syntax to use in an IF statement or can the statements even be this complex?  Or does this not do what I think it does?

      0(0).PV1(0).#10(0)  ne =OBS ||  0(0).PV1(0).#10(0)  ne =NRY ||  0(0).PV1(0).#10(0)  ne =OOB ||  0(0).PV1(0).#10(0) ne =OBV  

      Thanks.

    Viewing 7 reply threads
    • Author
      Replies
      • #78700
        Ed Mastascusa
        Participant

          Hello Danny – That syntax seems OK but the boolean logic in that statement is going to be true 100% of the time.  if you want to execute the “if” when PV1:10 is one of {OBS,NRY,OOB, OBV}, then the “ne”s should be “eq”s  or if you want the opposite then you need to change your “||”s to “&&”s

        • #78701
          Danny Wheeler
          Participant

            I want only these messages {OBS,NRY,OOB, OBV} to not trigger the IF statement (suppress).  What I need is everything that is not {OBS,NRY,OOB, OBV} to trigger the IF statement and suppress.  Am I using the wrong logic here and if so how do you recommend doing this in an Xlate?

          • #78702
            Jim Kosloskey
            Participant

              Danny,

              You could do this 2 ways and it would work but based on your desire to have the SUPRESS activated when the MSH-10 has certain values then

              I would try using EG with the connector being || (or).

              so IF MSH-10 eq NRS || eq NRY || eq OOB || eq OBV

              email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

            • #78703
              Keith McLeod
              Participant

                How about changing the NE to EQ and place the suppress in the main logic.

                That way if any are those values, it should suppress them.

                Just a thought.

              • #78704
                Tom Rioux
                Participant

                  Just a little tip for those behind you that may troubleshoot an issue later:

                  Whenever I place a suppress in an xlate, I always put a copy statement (that copies nothing) just before the suppress that simply has an echo statement in it.   The echo statement will give the reason why the message was suppressed and will print to the log file.  

                  Sometimes the suppresses can be buried and hard to find in an xlate.   Being able to see that echo in a log file has helped me in the past.

                  Thanks….

                  Tom Rioux

                • #78705
                  Danny Wheeler
                  Participant

                    Thomas.  This would be great tool.  Can you please tell me how you place the echo in the copy?  I am completely new to Cloverleaf and the syntax is what really has me confused.  Thanks.

                  • #78706
                    Ed Mastascusa
                    Participant

                      Hello Danny,

                      If I read your second post right, you want to exec a SUPPRESS when PV1:10 is NOT one of {OBS,NRY,OOB,OBV}  so you want to “AND” (&&) and not OR (||) your individual “ne” conditions in the original “IF” statement like this:

                      IF   0(0).PV1(0).#10(0)  ne =OBS &&  0(0).PV1(0).#10(0)  ne =NRY &&  0(0).PV1(0).#10(0)  ne =OOB &&  0(0).PV1(0).#10(0) ne =OBV

                        SUPPRESS

                      (no else)

                      re the echo statement, just make a COPY operation like Thomas suggested and put it above the suppress inside the if.

                      source: 0(0).PV1(0).#10(0)

                      dest: @scratchVar

                      in the “pre-proc” make sure TCL is chosen and put in this code snippet as a starting point. once you get comfortable with TCL and the xlt parameters you can get more complicated than this.

                      set temp [lindex $xlateInVals 0]

                      echo “suppressing message: PV1:10 is “$temp””

                      When you run the xlate tester then when the copy statement containg this pre-proc execs you’ll see the output and when you run for real it’ll  show up in the process log file.

                    • #78707
                      Gene Salay
                      Participant

                        To dumb it down a little …

                        (because clarity can save time in the future)

                        (although this is admittedly bigger and slower),

                        … you could do something like this:

                        Copy {OBS,NRY,OOB,OBV} to @RightOnes

                        Copy 1 to @Trash

                        ….

                        Copy 0(0).PV1(0).#10(0) to @ThisService

                        If @RightOnes ct=@ThisService

                        Copy 0 to @Trash

                        If @Trash

                         Suppress

                    Viewing 7 reply threads
                    • The forum ‘Cloverleaf’ is closed to new topics and replies.