using xlateOutVals with list context

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf using xlateOutVals with list context

  • Creator
    Topic
  • #48165
    Walter Ericson
    Participant

      Hi all,

      I am having a problem understanding what is happening when I set xlateOutVal.

      I have a variable that I am using to compare values.  It starts out as a single character field, using special characters.

      To compare certain special characters I am putting a “” before it in the variable.  For instance input field is “]” and the variable @lbracket is “]”.

      The variable is passed into a tcl frag and I use it in a “$” variable.

      When I use the following the output field is set correctly “[“:

      set xlateOutVal $field1

      When I use the following I get “” in the output field.

      set xlateOutVal

        I can echo both the $xlateOutVal and $field1 and they appear the same – “]”.

        I thought that the list context was the proper way to do it.

        I can fix the field, I just want to know why the non-list method appears as “]”?

        Thanks for any explaination you can give.

        -Walter Ericson

        St Lukes Hospital

    Viewing 0 reply threads
    • Author
      Replies
      • #57884
        Anonymous
        Participant

          Walter,

          Since set is s string command and list is a list command they react differently to special characters.  The set command produces a simple string and the list command produces a valid list.

          hcitcl>set myvar $

          hcitcl>puts $myvar

          $

          The TCL interpreter treated the as a substutition character.  So, “$” was evaluated to just $.  You’re really saying substutite “$” with $.  Then the set command took that value and simply put it into the variable as is.

          hcitcl>set myvar

            hcitcl>puts $myvar

            {$}

            In this case two things happen.  First, substitution occurs as before and the “$” is substutited with “$”.  Then the list command evaluates the $ and decides that since it’s a special character that it should use curly braces to prevent the interpreter from corrupting the list later on.  

            I’d have to play with it to see what happen when the value is passed back to the destination field.  The reason we’ve used list to set xlateOutVals was to guarantee that we passed only one list element.  In other words to prevent values that have spaces from being treated as multiple values.

            You may have seen the effect before:

            set xlateOutVals “hello world”

            The field actually contains only “hello”.  This is because hello was list element 0 and world was list element 1.  If there was only one destination path defined, element 1 has nowhere to go.

            So if you want “hello world” to show up in your field then:

            set xlateOutVals

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