Estava com essa dúvida outro dia no trabalho, pesquisei no manual da linguagem e achei a seguinte solução.
Segue exemplos do código:
puts novastr [format "|%-25s|" hello]
Saída: |hello |
set novastr [format "|%-*s|" $qtd $str]
Outras opções que um amigo me enviou:
set novastr $str[string repeat " " [expr {25 - [string length $str]}]]
efor {set novastr $str} {[string length $novastr] < 25} {} {
append novastr " "
}
Att, Emanuel Moraes
Nenhum comentário:
Postar um comentário