suppress in a xlate tcl fragment

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf suppress in a xlate tcl fragment

  • Creator
    Topic
  • #49770
    Todd Horst
    Participant

    I need to do one of the following in order to finish my xlate. Could someone give me a tip on how to do this?

    Background:

    I have a list variable throughout the entire xlate that is created in a tcl fragment at the start of the xlate.

    I need to:

    A. Have an IF statement that references the list variable. If there are 0 items in the list then kill (suppress) the message. If there are items then continue on with the message. I’ve been unable to do this because it says

    Quote:

    [0:TEST] IF expression parse failed: Expected ‘(‘ or Identifier

    Error occurred at: ‘{[llength $lr] > 0}’

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

    Or a similar message to that. My if statement looks like one of the 3 following, but nothing seems to work. (note, these all arent typed in at once, just one at a time)

    Quote:

    ([llength $lr] > 0)

    or

    [llength $lr] > 0

    or

    {[llength $lr] > 0}

    B. Another thought was to do this in a tcl fragment, then I can check the length and put it in an IF statement easily. But how, in a tcl fragment, do I suppress a message.

    My code for that way would look like this in a fragment

    Quote:

    if {[llength $lr] > 0} {

    echo greater than 0

    } else {

    echo less than or equal to 0

    #we need to kill the message since there aren’t items in the list

    }

    Thank you for taking a look.

Viewing 3 reply threads
  • Author
    Replies
    • #63515
      Tom Rioux
      Participant

      It seems I remember having trouble with the > and < operands inside an xlate once before.  I ran into the same error you are getting.  I got around it by using "expr" IF {[expr [llength $lr] > 0 ]} {

        then do something

      } else {

       do something else

      }

      Try that and let me know if it works for you.

      Thanks….Tom Rioux

    • #63516
      Jim Kosloskey
      Participant

      Todd,

      If I were to do this inside the Xlate (which is not the first place I would choose), what I would do is have the Tcl proc set an XlateOutVal (probably a temp variable) to the length.

      Then inside the Xlate us the IF to do the test for the temp variable greater than whatever and if true SUPPRESS the message.

      You could do an xpmdispose from inside the proc to KILL but I would think if you were going to filter inside the Xlate you would want that activity exposed and not hidden inside a proc.

      Jim Kosloskey

      email: jim.kosloskey@jim-kosloskey.com

    • #63517
      Todd Horst
      Participant

      Thanks guys,

      I went with Jim’s idea. I couldn’t use a variable in the if statement for some reason so….

      I had a copy statement and inside set the xlateoutval variable to the length of the list, then copied that into an out field.

      Then I had an if statement to check the field and if it wasnt > 0 then suppress the message, if it was greater then i would overwrite the list length field we an item in the list and then copied each of the other items in the list in thier respective fields.

      So thanks guys.

      The reason i used xlates was so i could have the output be in a fixed length file.

      Can you use a tps proc to write out to a frl?

    • #63518
      Jim Kosloskey
      Participant

      Todd,

      Certainly use an Xlate to reformat the message, but you could use a Tcl proc to filter the messages and apply the Tcl proc pre Xlate in the routing definition.

      As a general rule it is more efficient to filter messages before translation (so the only messages that get even prepared for translation are those that need to be translated).

      So IB Thread —> Route (Tcl Filter inside the routing) –> Xlate (transfom message) –> OB thread.

      Of course the above is a generalization.

      Jim Kosloskey

      email: jim.kosloskey@jim-kosloskey.com

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

Forum Statistics

Registered Users
5,073
Forums
28
Topics
9,251
Replies
34,230
Topic Tags
275