hi Bill,
This should do what you want more or less, it uses CF Script, Except this
will also check for the Existing CR&LF characters and bearck naturally. It
will search backwards for the last space before a word rather than search
forward.
Amend Linelength to match requirements. The Output is in TmpActual which is
an Array.
iLine is the Line count Amend it from 2 to 1,
Theres also probably a better way to do this, but it works,
<cfscript>
iLine=2;
LineLength=64
TmpActual=Arraynew(1);
MsgOperator=Replace(Form.Message,Chr(10),"}","ALL");
MsgOperator=Replace(MsgOperator,Chr(13),"}","ALL");
while (len(MsgOperator) gt 0){
TmpNote="";
if (len(MsgOperator) gt LineLength)
TmpNote=Mid(MsgOperator,1,LineLength);
else
TmpNote=Mid(MsgOperator,1,len(MsgOperator));
pos=Find("}}",TmpNote,1)-1;
if (pos lte 0){
pos=Len(TmpNote);
if (pos eq LineLength){
for (pos;pos gt 0 and Mid(TmpNote,pos,1) neq
" ";pos=pos-1);
if (pos eq 0)
pos=Len(TmpNote);
}
}
Miss_Line=FALSE;
if (Find("}}",TmpNote,1) eq 1){
pos=2;
Miss_Line=TRUE;
}
if (not Miss_Line){
TmpActual[iline]=
Ljustify(Mid(TmpNote,1,pos),LineLength);
iLine=iLine+1;
}
if (Find("}}",TmpNote,1) gte 0)
pos=pos+2;
else
pos=pos+1;
MsgOperator=Mid(MsgOperator,pos-1,len(MsgOperator));
}
iLine=iLine-1;
</cfscript>
HTH
Jason Lees
National Express
Email : [EMAIL PROTECTED]
-----Original Message-----
From: Bill Poff [mailto:[EMAIL PROTECTED]]
Sent: 30 May 2001 15:45
To: CF-Talk
Subject: How do I parse strings?
Hello fellow CFers,
I'm trying to process a "textarea" variable and break it up into lines of
aprox 70-80 characters in length for transmission as a text formatted email
message.
Can someone help me with the code to parse the variable into lines so that I
can insert a #CHR(13)##CHR(10)# at the end of every line. The challenge is
to break between words.
Thanks.
--Bill
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists