>I need some help on a best (quickest) way to break a memo field down. Here is the scenario:
>
>I have to read in a set of characters into a memo field.
>Once they are in the memo field I need to break them every 75 characters with a Carriage Return Line Feed, but I don't want to break them on a word.
>I want to back down until I get to a space and then put in the carriage return line feed.
>
>So does anyone have a code solution that would quickly do this as I am dealing with a large amount of data.
>
>TIA
How about:
lcText = MyMemo
lnPos = 75
lnSpaces = 0
DO WHILE lnPos < LEN( lcText)
*-- Find the position of the space nearest to lnpos
*-- Step 1 get the number of spaces between the start and lnPos
lnSpaces = OCCURS( " ", LEFT( lcText, lnPos))
*-- Step2 Find the position of the space
lnPos = ATC( " ", lcText, lnSpaces)
*-- Insert a CRLF after the space
lcText = STUFF( lcText, lnPos + 1, 0, CRLF)
lnPos = lnPos + 75
ENDDO
REPLACE NEXT 1 MyMemo WITH lcText
<\pre>
Mace