Adding a line to beginning of OBX in Xlate

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Adding a line to beginning of OBX in Xlate

  • Creator
    Topic
  • #53833
    Rob Parnell
    Participant

      I am trying to add an OBX to the beginning but it seems to always over write what is in OBX 0.  Here is my code.  I can write it in tcl but trying to use the Xlate

      { { OP COPY }

         { ERR 0 }

         { IN =0 }

         { OUT {{$%l1}} }

      }

      { { OP COPY }

         { ERR 0 }

         { IN {{=This is a final Report}} }

         { OUT {{1(0).1(0).1(%l1).OBX(0).#5(0).[0]}} }

      }

      { { OP ITERATE }

         { BASIS 1(0).1(0).1 }

         { VAR %g1 }

         { TYPE group }

         { BODY {

             { { OP COPY }

                 { ERR 0 }

                 { IN 1(0).1(0).1(%g1).OBX(0).#1(0) }

                 { OUT 1(0).1(0).1(%l1).OBX(0).#1(0) }

             }

             { { OP ADD }

                 { ERR 0 }

                 { IN {{=1 $%l1}} }

                 { OUT {{$%l1}} }

                 { FUNCTION ADD }

             }

      Here is the result.  First OBX gets overwritten  and line number is 22 not one

      1(0).1(0).0(0).OBR(0)  :  >|||4434|1^Consultation Report|||201309041101< 1(0).1(0).1(0).OBX(0)  :  >|22|TX|GDT||This is a final Report||||||F< 1(0).1(0).1(1).OBX(0)  :  >|2|TX|GDT|| ||||||F< 1(0).1(0).1(2).OBX(0)  :  >|3|TX|GDT||Testing a consultation report… 123||||||F< Should be 1(0).1(0).0(0).OBR(0)  :  >|||4434|1^Consultation Report|||201309041101< 1(0).1(0).1(0).OBX(0)  :  >|0|TX|GDT||This is a final Report||||||F< 1(0).1(0).1(1).OBX(0)  :  >|1|TX|GDT||This report is for testing |||||F< 1(0).1(0).1(2).OBX(0)  :  >|2|TX|GDT|| ||||||F< 1(0).1(0).1(3).OBX(0)  :  >|3|TX|GDT||Testing a consultation report… 123||||||F<

    Viewing 0 reply threads
    • Author
      Replies
      • #79130
        Levy Lazarre
        Participant

          Hi Rob,

          If you are building a new OBX segment (and not replacing an existing one), you need to build it completely from scratch, meaning that you need several COPY statements to create at least OBX. #1, #2, #3, #5, and #11.

          At this point, you only have one COPY statement to create the OBX. #5. The one for the set ID (OBX. #1) is missing; this is why you are getting the incorrect value (22) in the output. You should copy your counter value to that field:

          COPY $%l1  —> OBX. #1 and so on

          COPY =F     —> OBX. #11

          Once you have completed the manual construction of this additional OBX segment, you need to increment your counter once BEFORE you get in the ITERATE loop (so that you don’t overwrite an existing OBX segment).

          So after your COPY statements, you should have

                   { OP ADD }

                    { ERR 0 }

                    { IN {{=1 $%l1}} }

                    { OUT {{$%l1}} }

                    { FUNCTION ADD }

          Of course, you continue incrementing the counter inside the ITERATE as you have done.

          To avoid confusion, it’s always better to use a variable other than %l1 for your own counter. If you search the forum, you will find many excellent posts on this subject.

          I hope this helps.

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