XLATE HELP

  • Creator
    Topic
  • #48475
    Femina Jaffer
    Participant

      Can anyone help with the following, as my knowledge with xlates is vague.

      I need to check all OBX segments and determine if the sub id is greater then 1.  If so, I need to replace that particular segment from OBX to NTE.  I will need to repeat this for any OBX segments that have sub ids greater then 1.  I understand or believe that I will need to use an iterate as well, but am not too sure how to do this either.

      When I attempted to do this with the first step, using an IF statement :

      1(0).OBX.00572  > 1

      I encountered the error:

      [0:TEST] Unrecognized field name ‘Can’t locate segment in path.  1’

      [0:TEST] IF expression parse failed: Value references must yield exactly one datum      Error occurred at: ‘1’

      Any assistance would be greatly appreciated.  If anyone has done anything like this please advise or attach sample code for this request.

      Thanks

      FJ

    Viewing 8 reply threads
    • Author
      Replies
      • #58723
        Bill Bertera
        Participant

          I believe you need to preface the 1 with =:

          1(0).OBX.00572  > =1

        • #58724
          Femina Jaffer
          Participant

            Thanks William, but that didn’t work either.  The error now goes away, but the condition now allows the 1 too meet the criteria.  I need to do stuff if it is > then 1 and NOT = 1.

            FJ

          • #58725
            Anonymous
            Participant

              Hi Femina,

              Its been a while since the Lovelace days!  About your xlate, it sounds like that the OBX.572 field is poplulated with probably a two or more subfields.  If so, then you will need to specify which subfield you want by adding the .[0] or .[1] at the end.  Email me at trioux@tmh.tmc.edu if you want to chat further about it

              Tom Rioux

            • #58726
              Rentian Huang
              Participant

                Femina,

                =1 just means 1, NOT equal to 1. you still do 1(0).OBX.00572  > =1

                I guess you are also missing the Iteration Variable.

                ie. 1(0).OBX(%s1).00572 > =1

                sam

              • #58727
                Femina Jaffer
                Participant

                  Thanks Sam.  But it still does not work.  The error message disappeared and now it is doing what it is supposed to do regardless whether the subfield is 1 or greater then one – it doesn’t seem to care.

                  Thanks again.  I’m scratching my head here!

                  FJ

                • #58728
                  Anonymous
                  Participant

                    Could it be that the field you are using in the IF statement is not numeric, so its really not doing what you want it to do? I’m scratching my head about the same kind of IF statement I’ve been attempting… Do I need to make both my compare fields Numeric inorder to get the result I’m seeking? For example, is fld A less than zero? So fld A should be numeric, correct?

                    When you use the MATH command on fields do they both have to be numeric too?

                    Thanks, Mary.

                  • #58729
                    Anonymous
                    Participant

                      For some reason, the IF statement doesn’t like strings or numbers that aren’t set inside a variable.  I can never get it to work unless I set it to a variable first.   Then use the variable name (ex.  @tmp or @OBX4) in place of the number in the IF statement.  Also, as said previously, don’t forget to use the iteration variable (%g1) inside the IF statement if it is within the iterate.  Let me know if it works for you.

                      Tom

                    • #58730
                      Vince Angulo
                      Participant

                        I think you also have to remember that tcl is string based.  You shouldn’t be using the >,<, = operators. Try: IF 1(0).OBX(%s1).00572.[0] gt =1 Note the “gt” instead of “>”

                      • #58731
                        Femina Jaffer
                        Participant

                          Thank you everyone for all your assistance.  I did finally get my iterate and IF statement to work.  In fact, it was one of Arslan’s post regarding the same OBX / NTE issue that lead me to the correct path.  

                          The problem with my IF had to do with it being outside my Iterate.

                          Thank you all again!

                          Femina

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