CALL in Xlate

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf CALL in Xlate

  • Creator
    Topic
  • #49066
    garry r fisher
    Participant

      Hi,

      I have the following Tcl code setup as a pre-xlate and it works fine.

      proc xltStripZeroes {} {

         upvar xlateId       xlateId

       xlateInList   xlateInList

       xlateInTypes  xlateInTypes

       xlateInVals   xlateInVals

       xlateOutList  xlateOutList

       xlateOutTypes xlateOutTypes

       xlateOutVals  xlateOutVals

         set newval [string trimleft $xlateInVals 0]

         echo (newval = $newval)

         set xlateOutVals $newval

      }

      I want to try this as a CALL but simply changing the COPY to a CALL doesn’t work, nor does moving the Tcl to the Tcl section in the CALL command.

      Can somebody explain what changes if any are needed or how to setup CALL to use this type of code?

      Thanks

      Garry

    Viewing 6 reply threads
    • Author
      Replies
      • #60611
        Jim Kosloskey
        Participant

          Garry,

          A couple of things:

          What release of Cloverleaf and what platform?

          xlateInVals and xlateOutVals are lists and should be treated as such – this may not be your immediate problem but could cause problems in the future.

          What exactly is or is not occurring when attempting to CALL this proc?

          Jim Kosloskey

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

        • #60612
          Russ Ross
          Participant

            Garry:

            I recalled having answered how to do a CALL in an xlate on a previous post ( https://usspvlclovertch2.infor.com/viewtopic.php?p=5448#5448” class=”bbcode_url”>https://usspvlclovertch2.infor.com/viewtopic.php?p=5448#5448 ).

            I looked at that post and I saw you were the author.

            So referring you back to that post isn’t likely to be of much benifit to you.

            I’m sorry to see you’re still struggling with CALLs in Xlates.

            We are running Cloverleaf 5.2.1P2 under AIX 5.2 but we’ve been using CALLs in Xlates way before that.

            In any case, Jim is right treating xlateInVals as a list

                set newval [string trimleft [lindex $xlateInVals 0] 0]

            and treating xlateOutVals as a list

                set xlateOutVals

            is a good way to stay out of unecessary trouble.

            Russ Ross
            RussRoss318@gmail.com

          • #60613
            garry r fisher
            Participant

              Hi Jim/Russ,

              Yes – Still struggling with CALL.

              Setting it up as per your example Russ I’m not seeing the 0 been stripped off in the xlate testing tool. I’ll try Jim’s suggestion of using lists properly and see if it makes a difference.

              FYI – V5.3 on Windows 2K.

              Regards

              Garry

            • #60614
              Charlie Bursell
              Participant

                One question I always ask in my Level 2 and Level 3 classes  and no one ever knows the answer is “What is the difference between a CALL and a COPY in Xlate?”

                A COPY does an implicit copy of the in to the out.  There will *ALWAYS” be something copied to the output.  By default, xlateOutVals will be equal to xlateInVals.  It will change only if you modify it.

                A CALL is an explicit copy.  Unless you explicitly copy something to the output it is as if the statement did not exist.  You copy to the out put by using the xpmstore command.  Setting xlateOutVals does nothing!

                See, a free lesson and you didn’t even have to pay for the course  ðŸ˜‰

              • #60615
                Russ Ross
                Participant

                  Charlie:

                  I really like your post and you can add me to the list of those that did not know what you shared with us today.

                  I had always wondered when I should use a COPY or a CALL.

                  I did not know that you had to use xpmstore when doing a CALL.

                  However, by chance when I use xpmstore I have tended towards using a CALL.

                  I suppose I have never used anything but xpmstore when doing a CALL esle I would suffer, too.

                  Just dumb luck; so even a blind squirel can find an acorn once in a while.

                  I would be interested to know if there are other factors beside having to use xpmstore that would influence your decision to do a CALL instead of a COPY.

                  Jim Kosloskey and I had talked about this in the past and one thing Jim mentioned as an influencing factor was to do a CALL if you are not going to use the xlateOutValues (ex: using xpmstore to create segments on the outbound message that don’t exist on the inbound message).

                  Russ Ross
                  RussRoss318@gmail.com

                • #60616
                  Charlie Bursell
                  Participant

                    Russ:

                    I use CALL if I am going to be writing to several diverse addresses which are sometimes computed on the fly.  I also use it when if the input value does not match a certain criteria, I do not wish to put anything, even a null, to the output.

                    A lot of it also has to do with individual style.  There is nothing that says you cannot use xpmstore from within a COPY as well.  But in that case you have to also handle what is going to xlateOutVals.

                    It’s hard to pin it down as to when I would and would not use it.  It’s more of a gut feel when the situation comes up.

                    I guess this is about as clear as mud  ðŸ™„

                  • #60617
                    garry r fisher
                    Participant

                      Hi,

                      Who could ask for more. A free lesson on COPY/CALL from Charlie:-) I’ve never used xpm functions I was simply trying to answer Charlies question to his level 2/3 classes for myself.

                      Looks like I need to revise xpmnow.

                      Thanks for your help – as always its much appreciated.

                      Garry

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