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 <> " "
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})
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 <> " "
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})