IF IN rather than IF eq

Clovertech Forums Cloverleaf IF IN rather than IF eq

  • Creator
    Topic
  • #116049
    Simon Jamison
    Participant

      I need to use an IF statement like in SQL:

      IF xxx IN (‘A’,’B’,’C’)

      Is this possible?

      Many Thanks

       

    Viewing 5 reply threads
    • Author
      Replies
      • #116050
        Paul Bishop
        Participant

          Is this in TCL or a translate?  If a translate, there isn’t a way to check to see if a field is multiple values.  You have to do “if $x eq =1 || $x eq =2” and so forth.  TCL is the same way in the if statement, but there is the switch statement which can have multiple values:

          switch -exact — $x {

          1 –

          2 –

          3 {do something}

          default {do something}

          }

          Paul Bishop
          Carle Foundation Hospital
          Urbana, IL

        • #116062
          Vince Angulo
          Participant

            It would be kludgey, and I’ve never done it in a translate, but if the values of A, B and C are static, lsearch might work.

          • #116063
            Jim Kosloskey
            Participant

              You could use a table. place the values to be checked against in the left hand column and something consistent (like ‘Y’) in the right hand column with the default being something like ‘N’.

              Then in the Xlate TABLE Action pointing to your table and the data item to be checked giving a temp variable followed by an IF testing the temp variable for a value of ‘Y’.

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

            • #116100
              Simon Jamison
              Participant

                Sorry, translation rather than TCL .Will try the suggestions and get back to you.

              • #116283
                Simon Jamison
                Participant

                  Hi,

                  Paul’s idea of:

                  if $x eq =1 || $x eq =2

                  works OK and I was going to use it but it turns out that in the live environment there are 7 or 8 instances mapping to 1 so too many to hard code especially if changes need to be made for other hospitals using this in future.

                  Anyway, I now want to try your idea Jim. I have used a table before and indeed if there was only this position to map I would just use one without an IF but other positions in the field (PV1-8) depend on this value.

                  Could you expand on how to use the variable in conjunction with the table? I’ve used a variable in an ITERATE but that’s all.

                  If it’s any help in an example I’m mapping (simplified):

                  GP, GPN, GPR to GP

                  CON, CPN, CAN to CON

                  Many Thanks.

                • #116285
                  Jim Kosloskey
                  Participant

                    email me and we can discuss off line.

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

                Viewing 5 reply threads
                • You must be logged in to reply to this topic.