I need help with the Contains option on an IF…

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf I need help with the Contains option on an IF…

  • Creator
    Topic
  • #53695
    Corey Lewis
    Participant

      Actually I need to know how I would check a field if it does not contain a value.  I tried to do IF field !ct =Value but the compiler doesn’t like that.

      Any help would be appreciated.

      Thanks

      Corey

    Viewing 7 reply threads
    • Author
      Replies
      • #78584
        Jim Kosloskey
        Participant

          Corey,

          Here is how I do that:

          Do the IF with ct (not !ct) and have an else.

          The else is taken if the contains is not true.

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

        • #78585
          Corey Lewis
          Participant

            Jim,

            Thanks for the reply.  I thought of doing that but wasn’t fond of having an IF that didnt’ do anything just to get the else.  Something that goes back to my RPG days.  

            So here is my IF and my next question:

            0(0).DSP(%s3).#3(0).[0] ct =NO GROWTH ||

             0(0).DSP(%s3).#3(0).[0] ct =NEGATIVE ||

             0(0).DSP(%s3).#3(0).[0] ct =PENDING

            Would the else get anything that is not equal to NO GROWTH or NEGATIVE or PENDING?  I think it would but still not sure.

            Or would 3 seperate IF/ELSE statements be the way to go?

          • #78586
            Chris Williams
            Participant

              Corey,

              This issue has come up before. It’s a simple syntax issue. The operator “! ct” is not valid. If you don’t want to use the ELSE clause, you can negate the IF statement by placing the exclamation point before the comparison. Don’t forget the parentheses.

              Wrong:

            • #78587
              Jim Kosloskey
              Participant

                Chris,

                Excellent suggestion – I frequently forget about the parens.

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

              • #78588
                Corey Lewis
                Participant

                  So here is my IF statement…

                  IF

                  0(0).DSP(%s3).#3(0).[0] ct =CULTURE &&

                  !(0(0).DSP(%s3).#3(0).[0] ct =NO GROWTH &&

                   0(0).DSP(%s3).#3(0).[0] ct =NEGATIVE &&

                   0(0).DSP(%s3).#3(0).[0] ct =PENDING)

                  So that should get me any DSP segment with the word CULTURE and anything that is not NO GROWTH or NEGATIVE or PENDING.

                  SO this DSP Segment…

                  D S P | | |       C U L T U R E                                 2 +   S T A P H Y L O C O C C U S   A U R E U S

                  would drop into my IF criteria, correct?

                  And this DSP Segment would not drop into the IF.

                  DSP|||   CULTURE                NO GROWTH 2 DAYS PRELIMINARY, FINAL RESULT TO FOLLOW                                      

                  Correct?

                • #78589
                  Chris Williams
                  Participant

                    First, you need to deal with the space between NO and GROWTH. Probably you should put the phrase into a variable like @NOGROWTH.

                    Code:

                    IF
                    0(0).DSP(%s3).#3(0).[0] ct =CULTURE &&
                    !(0(0).DSP(%s3).#3(0).[0] ct @NOGROWTH) &&
                    !(0(0).DSP(%s3).#3(0).[0] ct =NEGATIVE) &&
                    !( 0(0).DSP(%s3).#3(0).[0] ct =PENDING)


                    Contains CULTURE and NOT NOGROWTH and NOT NEGATIVE and NOT PENDING, if that’s what you’re going for..

                  • #78590
                    Corey Lewis
                    Participant

                      Thanks Chris.  I will give that a shot.

                    • #78591

                      Corey, I find anything other than a very simple CONTAINS condition easier and safer to do in a tcl fragment.

                      -- Max Drown (Infor)

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