|
Post by honkytonk on May 1, 2019 9:29:30 GMT
Hello, I have a texteditor with line breaks (return at line); I would like to transfer the contents to a file by replacing the line returns with a space; is it possible by the code ?
|
|
|
Post by tenochtitlanuk on May 1, 2019 14:01:22 GMT
Here's an example which will either save the texteditor contents as a normal file, or replace CR/LF with spaces. Note text editor does not itself do word-wrap.. you may be doing it yourself programmatically? If your editor uses CRLF ( chr$( 10) +chr$( 13) it'll cresate a double-space. Could easily change that.
nomainwin
WindowWidth =600 WindowHeight =500
texteditor #w.te 10, 10, 400,400 button #w.b1 "Save +CRLF", [saveFile1], LR,150, 90 button #w.b2 "Save -CRLF", [saveFile2], LR,150, 30
open "Demo" for window as #w
#w "trapclose [quit]" #w.te "!font 16" #w.b1 "!font 12" #w.b2 "!font 12"
wait
[quit] close #w end
[saveFile1] #w.te "!contents? content$" open "outFile1" for output as #fOut #fOut content$ close #fOut wait
[saveFile2] #w.te "!contents? content$" open "outFile2" for output as #fOut for i =1 to len( content$) c$ =mid$( content$, i, 1) if c$ =chr$( 10) or c$ =chr$( 13) then #fOut, " "; else #fOut c$; next i close #fOut wait
|
|
|
Post by honkytonk on May 1, 2019 15:52:59 GMT
Thank you véry much, it's work véry well.
|
|