2017-09-13 68 views
1

我將變量中的文本添加到文件中,並在80個字符後分到下一行。從文本90個字符後的tcl分割變量

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 
} 

例如WO我想補充

這是一個變量:從「當」結束是「曾向」開始。

!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

80個字符的新行\ n之後〜怎麼弄。首先從示例開始,然後在「成熟」之後,接下來在「驚人」之後。 ....

+0

似乎沒有在這裏是一個問題,你能清楚地陳述問題是什麼? – CyanAngel

+0

這是一個變量:從「何時」開始到「結束」是「選擇」。 !maketext當柯南離開NBC時,深夜與吉米法倫是唯一脫口秀節目,那還算不錯。然而在過去的一年裏,吉米和史蒂夫希金斯一起成長爲一位熱鬧的即興創作人,他們的化學成就令人驚歎。這兩個使指定 如何使~80個字符後新行\ n。首先從示例開始,然後在「成熟」之後,接下來在「驚人」之後。 .... – revoq

回答

2

這很容易與::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 

如果一個人帶走了-strictlength選項或將其設置爲false,該命令將允許單個的詞去超過限制。

文檔: textutil (package)

+0

不錯的大thx,工作正常:)問候 – revoq