2017-09-13 1 views
1

J'ajoute le texte des variables au fichier et je dois diviser après 80 caractères à la ligne suivante.tcl diviser la variable après 90 caractères

bind pub "-|-" !maketext pub:textmaker 
proc pub:textmaker { nick host handle channel arg } { 

    set fid [open text.txt w] 
    puts $fid "." 
    puts $fid "asdflk asdkflasdfioasd fasdf as dfa sdf a sdf" 
    puts $fid "." 
    puts $fid "$arg"  
    puts $fid "." 
    puts $fid "." 
    close $fid 
} 

exemple du texte wo je veux ajouter

Ceci est une variable: partir « Quand » mettre fin est « opiner ».

!maketext When Conan left NBC, Late night with jimmy Fallon was the only talk show that was left that was kinda Okay. However over the past year Jimmy has matured into a hilarious improviser along with Steve Higgins and their chemistry is amazing. Those two make the opining

Comment faire après ~ 80 caractères une nouvelle ligne \ n. Premier Après "parler" de l'exemple, et après après "mûri" et après après "étonnant". ....

+0

Il ne semble pas être une question ici, pourriez-vous indiquer clairement quel est le problème? – CyanAngel

+0

Ceci est une variable: commencez par "Quand" pour finir "opining". ! Maketext Quand Conan a quitté NBC, Tard dans la nuit avec jimmy Fallon était le seul talk-show qui restait qui était un peu OK. Cependant, au cours de la dernière année, Jimmy est devenu un improvisateur hilarant avec Steve Higgins et leur chimie est incroyable. Ces deux font l'opinion Comment faire après ~ 80 caractères une nouvelle ligne \ n. Premier Après "parler" de l'exemple, et après après "mûri" et après après "étonnant". .... – revoq

Répondre

2

Il est facile avec ::textutil::adjust:

% package require textutil 

% set s {When Conan left NBC, Late night with jimmy Fallon was the only talk show that was left that was kinda Okay. However over the past year Jimmy has matured into a hilarious improviser along with Steve Higgins and their chemistry is amazing. Those two make the opining} 

% ::textutil::adjust $s -length 80 -strictlength true 
When Conan left NBC, Late night with jimmy Fallon was the only talk show that 
was left that was kinda Okay. However over the past year Jimmy has matured into 
a hilarious improviser along with Steve Higgins and their chemistry is amazing. 
Those two make the opining 

Si l'on enlève l'option -strictlength ou mis à false, la commande permettra des mots simples pour aller au-dessus de la limite.

Documentation: textutil (package)

+0

belle grosse thx, fonctionne bien :) Cordialement – revoq