Using a variable to reference a field component

Clovertech Forums Cloverleaf Using a variable to reference a field component

  • Creator
    Topic
  • #119928
    David Teh
    Participant

      Hi folks,

      I have an Xlate proc trying to output to a field component.

      Tried using this but it seems to treat “[$ctr]” as blank and writes to the field instead.

      xpmstore $xlateId {~0(0).PV1(0).#52(0).[$ctr]} d -c “$line”

       

      What am I missing?

       

      TIA!

    Viewing 2 reply threads
    • Author
      Replies
      • #119929
        Charlie Bursell
        Participant

          That is because your variable is inside braces and is not evaluated.  Use quotation marks instead.  If you really need braces use the subst command

        • #119930
          David Teh
          Participant

            Hi Charlie,

            Trying to wrap my mind around this…..

            How would we output to a component without the square brackets?

          • #119931
            Charlie Bursell
            Participant

              A couple of different ways

              enclose in double quotes and escape the brackets with backslashes

              xpmstore $xlateId “~0(0).PV1(0).#52(0).\[$ctr\]” d -c “$line”

              or you could use the substitute (subst) command.

              set xlateid [subst -nocommands {~0(0).PV1(0).#52(0).[$ctr]}] d -c “$line”

              The first option would be better for documentation.  The second may confuse others nor familiar with the substitute command

          Viewing 2 reply threads
          • You must be logged in to reply to this topic.