maybe, it’s too late know, but i don’t find a useful solution to split a long text (>250 lines).
I have to fill comment lines (Text 80). It’s not that difficult, but I don’t just want so copy a srting with 80 signs (COPYSTR(TempText,Pos,MAXSTRLEN(CommentLine.Comment)); Doing it this way words are being cut. This does not look so good.
I want to find the last space in the Text 80 string blocks and copy everything left of the space. The new Position should be something like
Pos := Pos + CopiedStringLength.
PROCEDURE [Split@1140001(p_inputStr@1140000](mailto:Split@1140001(p_inputStr@1140000) : Text[250];VAR p_outputStr@1140001 : ARRAY [10] OF Text[250];p_maxLen@1140002 : Integer);
BEGIN
IF p_maxLen <= 0 THEN
ERROR(’“Max. Output Length” has to be greater than zero.’);
CLEAR(p_outputStr);
index := 0;
maxIndex := ARRAYLEN(p_outputStr);
REPEAT
index := index + 1;
splitPosition := STRLEN(p_inputStr);
IF splitPosition > p_maxLen THEN BEGIN
splitPosition := p_maxLen;
IF (COPYSTR(p_inputStr,splitPosition,1) <> ’ ‘) AND // split within word
(COPYSTR(p_inputStr,splitPosition + 1,1) <> ’ ‘)
THEN BEGIN
REPEAT
splitPosition := splitPosition - 1;
UNTIL (COPYSTR(p_inputStr,splitPosition,1) = ’ ‘) OR (splitPosition <= 1);
IF COPYSTR(p_inputStr,splitPosition,1) <> ’ ’ THEN
ERROR(‘Input string contains a word which is too long: “%1”’,p_inputStr);
END;
END;
p_outputStr[index] := DELCHR(COPYSTR(p_inputStr,1,splitPosition),’<>’,’ ‘);
p_inputStr := DELCHR(COPYSTR(p_inputStr,splitPosition + 1),’<>’,’ ');
UNTIL (p_inputStr = ‘’) OR (index >= maxIndex);
IF p_inputStr <> ‘’ THEN // better use a temporary record instead of p_outputStr
ERROR(‘Array overflow’);
END;
Rashed, There was just a little mistake in your function.
FindLastSpace(String : Text[100]) : Integer
For i := 1 to strlen(String) Do begin
if String[strlen(String)+1-i] = ’ ’ then exit(strlen(String)-i);
end;
@ghuebner: 3 Dimension assignments missed to compile the form, but it also works great to test!