TCL TPS need to pad to the right of a string

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf TCL TPS need to pad to the right of a string

  • Creator
    Topic
  • #52193
    Jerry Tilsley
    Participant

      All,

      I have figured out how to get the tcl string format command to pad some spaces to the left of a variable, but cannot seem to be able to get it to work with padding to the right.  

      I need to take the following:

      “PAYROLL”

      and turn it into:

      “PAYROLL              “

      Thanks!

    Viewing 2 reply threads
    • Author
      Replies
      • #73363
        Vince Angulo
        Participant

          I believe a hyphen in the format string to left justify:

          [format “%-20s” $variable]

          …if the padded result is 20 positions long.

        • #73364
          Keith McLeod
          Participant

            Not fancy, but works:

            set y “${x}[string repeat 0 [expr 14-[string length $x]]”

          • #73365
            Jerry Tilsley
            Participant

              Thanks everyone!

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