0

I'm new to tcl ,I like your help to give a dynamic variable spacing between words in Tcl. Example : "Stack over flow" " Stack" as 5 letter in it. So I have to give space of 5 to start next word same goes to next word.

Output: Stack     over    flow
sixz
  • 35
  • 6
  • `over` is 4 letters in length. Should it be `overf` instead? And did you try anything? – Jerry Mar 05 '19 at 07:56
  • Please edit your question to show exactly what you want to get out and what you put in. Surrounding those bits in `
    `…`
    ` (just like in HTML) will help you make the page give exact spacing.
    – Donal Fellows Mar 05 '19 at 10:27

1 Answers1

0

I suppose you could do something like this:

set example "Stack over flow"
set result ""

foreach word $example {
    append result $word [string repeat " " [string length $word]]
}

set result [string trim $result]
puts $result

Will give:

Stack     over    flow
Jerry
  • 70,495
  • 13
  • 100
  • 144