Getting an error using $% variables for counters.

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Getting an error using $% variables for counters.

  • Creator
    Topic
  • #54739
    James Phetteplace
    Participant

      Hello,

      This is very frustrating right now. I am trying to only copy over certain GT1-2 fields in an xlate. Setting a counter variable and using an if statement to copy over what fields I want and using the counter for my outbound so there is no blank GT1-2 fields in the message.

      GT1|1|baddata^SS~gooddata~moregooddata||||

      to

      GT1|1|gooddata~moregooddata||||

      Others here have used this before and we haven’t had any issues. When I compiled it I am getting this error.

      Quote:

      Command: hcixlttest FIN_CATH_ADT.xlt


      FAILED


      [0:TEST] Unrecognized field name ‘Invalid interpolation variable  %counter’

      [0:TEST] Unable to compile OUT list ‘{$%counter}’

      [0:TEST] Unable to compile statement ‘

      { OP COPY }

                         { ERR 0 }

                         { IN =0 }

                         { OUT {{$%counter}} }

                     ‘

      [0:TEST] Unrecognized field name ‘Invalid interpolation variable  %counter’

      [0:TEST] Unable to compile OUT list ‘{$%counter}’

      [0:TEST] Unrecognized field name ‘Invalid interpolation variable  %counter’

      [0:TEST] Unable to compile IN list ‘{$%counter} =1’

      [0:TEST] Unable to compile statement ‘

      { OP ADD }

                                         { ERR 0 }

                                         { PRE {

                                             echo “Counter In = $xlateInVals”

                                             echo “Counter Out = $xlateOutVals”

                                         }}

                                         { IN {{$%counter} =1} }

                                         { OUT {{$%counter}} }

                                         { FUNCTION ADD }

                                     ‘

      [0:TEST] Unable to compile XLT ‘FIN_CATH_ADT.xlt’.

      It seems like it doesn’t like my counter variables. Anyone have any idea?

      [/img]

    Viewing 2 reply threads
    • Author
      Replies
      • #82785
        Keith McLeod
        Participant

          Are you using this in conjunction an iterate?

          Try using $%s1 for segment, $%f1 for field, $%g1 for group, or $%l1 for list. They are very specific about the name format for these counters.  You can change the numbers in the variable name as needed so $%f2, $%f3…for example.

          If you use an iterate, it will automatically initialize the variable to 0.  I would suggest using an iterate inside a translate.

          See attached….

          My GT1 Repeats and GT1:2 repeats.

          I blank out GT1:2

          Initialize my outbound counter called $%f2 to 0

          I only update my outbound counter is I copy a field repetition.

        • #82786
          Jim Kosloskey
          Participant

            You can also use your own counter (I think that is what you are trying to do) inside an ITERATE or not BUT the names have to utilize the %g %s %f %l then number (like %g99). You are using %counter and that is not legal (thus the error).

            If you do use your own counteer you are responsible for managing it (that means initializing it and incrementing it as necessary).

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

          • #82787
            James Phetteplace
            Participant

              Thank you, I knew it was something stupid I was doing. I could have done this in a TCL Script but didn’t want to just for something like that.

              Thanks again.

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