":ct" operand in If compare

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf ":ct" operand in If compare

  • Creator
    Topic
  • #51045
    Bob Schmid
    Participant

    Can someone show me the syntax of using the string ct operator within a xlate if statement?…for example..I want to check a field for all numerics

    Thanks

Viewing 13 reply threads
  • Author
    Replies
    • #68546
      Tom Rioux
      Participant

      Hi Robert,

      We have used the string “ct” before but not as you requested.  We have used it to check to see if a string contains a literal such as “INT”.  Here is the example:

      0(0).PV1.#2.[0] eq =R && 0(0).PV1.#10.[0]  ct  =INT

      I’m not sure if the “ct” string command can be used in the way you want.   What we have done here is taken the inbound value and run it through a pre-proc to check to see if the field is numeric.  If so, then perform some function.  In our case, we set it to a variable called @isnumeric to be used later in the xlate.

      Hope this helps…

      Tom Rioux

    • #68547
      Bob Schmid
      Participant

      Thomas…

      at first blush…Im not sure I see the difference in your example between eq and ct.

      Thanks,

      Bob

    • #68548
      Bob Schmid
      Participant

      Coffee required in order to rightly interpret!  😯

      Thanks Jim for your email…that’s what we ended up doing! …used a pre-proc in the translate and  stinrg is digit check

      but…now I know about  ct-Contains  too!

    • #68549
      Tom Rioux
      Participant

      It would be nice if all solutions were submitted through Cloverltech instead of private emails.  That way, everyone can share in the benefits of knowing all possible solutions.

      At least…that is what one Clovertecher told me a while back!   😀

      Thanks…

    • #68550
      Troy Morton
      Participant

      Is the ‘ct’ operator something that was added after 5.4?  I tried to use it and got an error when I tried to compile my Xlate.

      Troy

    • #68551

      Why send the solution in an email? Post it here so others with the same issue can search and find a resolution to the same issue.

      -- Max Drown (Infor)

    • #68552

      The “ct” operator means “contains”. The operator will search the field for the given string.

      If “hello, world!” contains “hello” then it will return true.

      Make sense?

      -- Max Drown (Infor)

    • #68553

      In your example above, you could also use a tcl fragment instead of a pre-proc.

      -- Max Drown (Infor)

    • #68554
      Tom Rioux
      Participant

      One caveat concerning the use of the “digit” class with the “string is” command.   If you have a negative value such as -1, then the “string is digit” command will return false.   It would probably best suit your purposes to use “string is integer”.

      Example:

      hcitcl>set a -1

      -1

      hcitcl>string is digit $a

      0

      hcitcl>string is integer $a

      1

      hcitcl>

      This bit me once already.

      Thanks….

      Tom Rioux

    • #68555
      Charlie Bursell
      Participant

      One other caveat to be aware Tom.

      If you do not use the -strict flag, the empty string will always return true.

      string is digit -strict $a

    • #68556
      Tom Rioux
      Participant

      Thanks for the tip Charlie….I was not aware of that flag

    • #68557
      Troy Morton
      Participant

      In what version of Cloverleaf does the “ct” operator become available?

      It doesn’t appear to be in Cloverleaf 5.4.

      Thanks,

      Troy

    • #68558
      Tom Arrowsmith
      Participant

      I also have 5.4.1 and was unable to use ct

      I am assuming it is not part of 5.4

      any thoughts?

      Tom

    • #68559
      Jim Kosloskey
      Participant

      I think that is first available in 5.6.

      email: jim.kosloskey@jim-kosloskey.com

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

Forum Statistics

Registered Users
5,042
Forums
28
Topics
9,200
Replies
34,023
Topic Tags
267