Use of a variable in a COPY/PRE PROC tcl frag in an Xlate

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Use of a variable in a COPY/PRE PROC tcl frag in an Xlate

  • Creator
    Topic
  • #55404
    Lawrence Nelson
    Participant

      Having an issue with using a variable in a COPY/PRE PROC tcl frag inside an xlate

      The intent is to copy PID:3 to PID:2 and to string map content out along the way –

      I’m trying to do this via a variable so I won’t have to custom code it time.

      PID:2 may or may not have data in it.

      My source side says takes these two pieces –

      @ORC13  (a variable set prior to the copy)

      1(0).0(0).0(0).PID(0).#3(0).[0]

      COPY        (NOT CONCAT)

      Run the source through a PRE PROC

      echo begin pre proc

      set ORC13 [ lindex $xlateInVals 0 ]

      echo ORC13 = $ORC13

      set PID3 [ lindex $xlateInVals 1 ]

      echo PID3 = $PID3

      set xlateOutVals [string map { $ORC13 “” } $PID3 ]

      echo PID2 out = $xlateOutVals

      echo end pre proc

      To a destination of

      1(0).0(0).0(0).PID(0).#2(0).[0]

      Issues –

      1: The Variable ($ORC:13) is not string mapped out as expected.

      2: PID:3 just appears to get copied into PID:2

      I gather I should be able to do this – using a variable in a string map. What am I doing wrong here?

      Thanks.

      Lawrence Nelson
      System Architect - MaineHealth IT

    Viewing 5 reply threads
    • Author
      Replies
      • #85201
        James Cobane
        Participant

          Lawrence,

          Remember to treat xlateOutVals as a list as well.  You should change your statement when setting xlateOutVals to treat xlateOutVals as a list (see below).  And to be clear, are you trying to replace the value (whatever $ORC13 is) with nulls in the $PID3 string and set xlateOutVals equal to that?  (i.e. if $ORC13 is “5”, and $PID3 is “123456785”, your output would be “1234678”)

          set xlateOutVals

            ]

            Hope this helps.

            Jim Cobane

            Henry Ford Health

          1. #85202
            Lawrence Nelson
            Participant

              James –

              You are correct –

              (i.e. if $ORC13 is “5”, and $PID3 is “123456785”, your output would be “1234678”)

              commented out my work and pasted in yours – No change in outcome.

              echo begin pre proc

              set ORC13 [ lindex $xlateInVals 0 ]

              echo ORC13 = $ORC13

              set PID3 [ lindex $xlateInVals 1 ]

              echo PID3 = $PID3

              #set xlateOutVals [string map { $ORC13 “” } $PID3 ]

              set xlateOutVals [ list [string map { $ORC13 “” } $PID3 ] ]

              echo PID2 out = $xlateOutVals

              echo end pre proc

              Lawrence Nelson
              System Architect - MaineHealth IT

            • #85203
              James Cobane
              Participant

                It does seem that the “string map” is not liking the use of the variable as one of key value elements.  If you take the same command and use a literal value instead of the variable, it seems to work.  i.e.

                set ORC13 5

                set PID3 12345678951

                set xlateOutVals

                  ]

                  puts $xlateOutVals

                  yields 12345678951, but if you do

                  set PID3 12345678951

                  set xlateOutVals

                    ]

                    puts $xlateOutVals

                    yields 123467891

                  1. #85204
                    Lawrence Nelson
                    Participant

                      So it still could be me – but is sure seems like I should be able to do this somehow without having to hardwire it. 😕

                      Lawrence Nelson
                      System Architect - MaineHealth IT

                    • #85205
                      James Cobane
                      Participant

                        Try this in your command:

                        set xlateOutVals [ list [string map

                          $PID3 ] ]

                          It should do the trick.

                          Jim Cobane

                          Henry Ford Health

                      • #85206
                        Lawrence Nelson
                        Participant

                          We have a winner! Please give that man a cigar and a chicken dinner!

                          Thank you for your solution!

                          Lawrence Nelson
                          System Architect - MaineHealth IT

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