REBOL [
    Title:   "Word Wrap Text"
    Date:    18-June-1999
    Author:  "Scrip Rebo"
    File:    %wraptext.r
    Purpose: "Handy function to fill and wrap a text paragraph."
    Category: [text util 3]
]

wrap-text: func [
    para
    /margin size "Char count after which the wrap occurs."
    /local count
][
    count: 1
    if not margin [size: 50] ; default size
    trim/lines para
    forall para [
    if all [count >= size find/match para " "][
        change para newline
        count: 0
    ]
    count: count + 1
    ]
    head para
]

print wrap-text {
       This is a paragraph that
       we want to
       fill and wrap using the default margin which is
       set to 50.
}