Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

truncate issue in CR Version 6

Status
Not open for further replies.

doanqa

MIS
Apr 3, 2003
2
US
I am trying to truncate a string after the 65th character. If the next character is not a space, then I need to go back until I reach a space and truncate there. I am basically trying to not chop words in half. The example I have includes Loop statements which, as far as I know, aren't supported in CR 6. CR 6 needs to be used. Can anyone help? This is what I have in CR 8.5:

If length({PMASTR.CMSNAM}) > 65 Then
If MID({PMASTR.CMSNAM}, 66, 1) = " " Then
LEFT({PMASTR.CMSNAM}, 65)
Else
stringvar lastChar := "a";
numbervar lastPos = 64;

Do While lastChar <> &quot; &quot;
do if lastpos > 0 then lastpos = 1 else lastPos = lastPos - 1
while lastChar = MID({PMASTR.CMSNAM}, lastPos, 1);
LEFT({PMASTR.CMSNAM}, (lastPos -1));
TRIM({PMASTR.CMSNAM})
 
I think that we can simplify this:
      
    LEFT(PMASTR.CMSNAM}, instrrev(mid({PMASTR.CMSNAM},1,66), &quot; &quot;)

Can't test right now, but the theory should get you there.

-k
 
thanks, that works perfect in 8.5

now I need to find if there is a DLF for 6
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top