Variable question

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Variable question

  • Creator
    Topic
  • #52031
    Kevin Crist
    Participant

      Is there an advantage to using variables in an xlate as opposed to copying to a field? I understand the need for variables but didnt know if in this case one line is ok since they arent being reused any where else in the xlate.

      I have the attached screen shot of an xlate, where there is formating for the dashes and they have some tcl in it.

      Is there a difference between doing it this way:

      currently:

      COPY   0(0).PID.00106(0).[0] -> @mrun (with tcl fragment)

      COPY   @mrun -> 0(0).PID.00106(0).[0]

      as opposed to this:

      COPY 0(0).PID.00106(0).[0] -> 0(0).PID.00106(0).[0] (with tcl fragment)

    Viewing 4 reply threads
    • Author
      Replies
      • #72795
        Julie Berg
        Participant

          I’m new to using tcl.  Could you share the tcl you used to remove the dashes from the ssn in this example.  thank you.

        • #72796
          Kevin Crist
          Participant

            sure thing, these were done years ago before i got here so

            i am sure there are people who can do this in one command or two, but i’m not one of them…yet

            this adds the dashes:

            lassign $xlateInVals mrunnum

            set xlateOutVals ()

            set mrun1 [string range $mrunnum 0 1]

            set mrun2 [string range $mrunnum 2 3]

            set mrun3 [string range $mrunnum 4 5]

            set xlateOutVals “$mrun1-$mrun2-$mrun3”

            this removes the dashes:

            lassign $xlateInVals socsec

            set xlateOutVals ()

            set soc1 [string range $socsec 0 2]

            set soc2 [string range $socsec 4 5]

            set soc3 [string range $socsec 7 10]

            set xlateOutVals “$soc1$soc2$soc3”

          • #72797
            Keith McLeod
            Participant

              Here are a couple of options:

              hcitcl>set ssn 999-99-9999

              999-99-9999

              hcitcl>string map {- “”} $ssn

              999999999

              hcitcl>regsub -all — {-} $ssn {} xlateOutVals

              2

              hcitcl>echo $xlateOutVals

              999999999

              hcitcl>

              I am sure there are many other ways as well.

            • #72798
              Shaun Beckman
              Participant

                This is the way we do it in an xlate copy statement:

                set indata [lindex $xlateInVals 0]

                set xlateOutVals

                  ]

                1. #72799
                  Jim Kosloskey
                  Participant

                    Whatever way you do it just make sure you are treating both xlateInVals and xlateOutVals as LISTS.

                    My .02 worth regarding the original question.

                    Sometimes using a temp variable can provide a benefit but many times it is simply a personal preference.

                    I think each situation needs to be evaluated individually and use what fits best.

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

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