Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

wrap - wrap-text

 [1/4] from: arolls:bigpond:au at: 31-Jul-2001 1:19


Replace this wrap-text function with yours found at: http://www.geocities.com/~jimclatfelter/wordwrap.txt I have used two newlines to indicate a new paragraph. So, you need to add a newline at the beginning of your supplied text. wrap-text: func [ para /margin size /local count ][ count: 1 if not margin [size: 50] ; default size ; (two newlines) -> (two newlines and some spaces) replace/all para "^/^/" "^/^/ " ; five spaces forall para [ if (first para) = newline [count: 0] if all [ count >= size find/reverse para " " ][ para: find/reverse para " " change para newline count: 0 ] count: count + 1 ] head para ]

 [2/4] from: hijim:pronet at: 30-Jul-2001 20:07


Hi Anton, Thanks for the wrap function. I took out the 5 spaces because I didn't want to indent the paragraph. I wanted to indent all the lines by 5 spaces. I put the new script at http://www.geocities.com/~jimclatfelter/wordwrap.txt I put the editor I'm trying to get to print is posted at http://www.geocities.com/~jimclatfelter/eddy.txt It's not very long. I could post it here if you like. The wrap function works in both programs. The only problem with the editor printing is the first line. It works the first time. I can print exactly what I see on the screen -- the same exact lines. When I print it again, the first line is messed up. I must not be clearing something in the printer, since it works fine on the screen. I'm not sure what string will clear the printer. Any ideas on how to get a 5 space margin on every line? That way I can print exactly what is on the screen with a 5 space margin on the left of the page. (I did manage to get a margin on all but the first line of each paragraph, but that isn't what I want.) I'd sure be glad for your help. Thanks, Jim Anton wrote:

 [3/4] from: arolls:bigpond:au at: 1-Aug-2001 3:03


> Thanks for the wrap function. I took out the 5 spaces because I > didn't want to
<<quoted lines omitted: 5>>
> exactly what is on the screen with a 5 space margin on the left > of the page.
Modifying my last example: wrap-text: func [ para /margin size /local count ][ count: 1 if not margin [size: 50] ; default size ; (two newlines) -> (two newlines and some spaces) replace/all para "^/^/" "^/^/ " count: 5 forall para [ if (first para) = newline [count: 0] if all [ count >= size find/reverse para " " ][ para: find/reverse para " " change para newline para: insert next para " " count: 5 ] count: count + 1 ] head para ]

 [4/4] from: hijim::pronet::net at: 31-Jul-2001 21:14


Hi Anton, Thanks for the new word wrap function. It didn't want to put a 5 space margin on the first line. I think that was because that paragraph was not preceded by newlines. So I added two newlines at the beginning and removed them at the end of the function's formatting. That made it work perfectly. I probably could have used better code than remove para "^/^/" "^/^/" ; remove two newlines at top remove para "^/^/" "^/^/" ; remove two more newlines at top but that does the work. I posted the revised editor at http://www.geocities.com/~jimclatfelter/eddy.txt I set the wrap length to 76. That way all lines get a maximum of 70 characters plus the 5 spaces at the beginning of the line. Thanks again! Jim wrap-text: func [ para /margin size /local count ][ insert para "^/^/" "^/^/" ; add two newlines at top count: 1 if not margin [size: 72] ; default size replace/all para "^/^/" "^/^/ " ; two newlines and some spaces count: 5 remove para "^/^/" "^/^/" ; remove two newlines at top remove para "^/^/" "^/^/" ; remove two more newlines at top forall para [ if (first para) = newline [count: 0] if all [ count >= size find/reverse para " " ][ para: find/reverse para " " change para newline para: insert next para " " count: 5 ] count: count + 1 ] head para ] Anton wrote:

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted