Forum > Beginners

Trouble with parseing(SOLVED)

(1/2) > >>

JLWest:
I'm gettin an error at line 18: unit1.pas(870,12) Error: Operator is not overloaded: - "AnsiString". I don't understand?

Var 2S : String = '    Notes: aaaa bb ccccccc  dddddddddd eeeeeee fffffff ggggg hh iiiiiii jjjjj kkkkkkkkkk llllllllll m n oooooooo pppppp qqqqqq rrrrrr sssssssss ttttt uuuuuuuuuuuuuu vvvvvv wwwwwwwww x yy zzzzzzz.                                                       

Sl is a TstringList I'm passing in and stores the reply.

It work somewhat but not really good. And with the error not at all

Call:  parseforlength(sToParse, SL );


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- procedure TForm1.ParseForLength(const sToParse : String;  SL: TStringList);  var S : String;   sInsert : String[14] = '              ';   p1, p2,s2P, Lgth : SizeInt;   sSize : Integer = 107;   s2Parse : String;   begin                                  s2Parse := sToParse;   s2P := Length(s2Parse);   if s2P <= sSize then begin SL.ADD(s2Parse); exit; end;   p1 := 5;  repeat   p1 := PosEx(' ', sToParse, p1);   if ( p1 > 0 ) then begin      p2 := PosEx(' ', s2Parse, p1 + 1 );      if (p2 > sSize) then begin         Insert( '|',s2Parse, P1 );             -         S := Copy2SymbDel(s2Parse, '|');         SL.Add(S);         s2Parse := Concat( sInsert, s2Parse);         if ( Lgth = 0 ) or ( s2P < sSize ) or ( p1 = 0) then begin             P1 := 0; P2 := 0;             s2Parse := Concat( sInsert, s2Parse);             SL.Add(s2Parse);             exit;         end else begin          p1 := 8; P2 := 1;         end;       end;        P1 := p2 + 1;     end;   until (p1 = 0) or (p2 = 0); end;  
Results should be:

'    Notes: aaaa bb ccccccc dddddddddd eeeeeee fffffff ggggg hh iiiiiii jjjjj kkkkkkkk
               llllllllll m n oooooooo pppppp qqqqqq rrrrrr sssssssss ttttt uuuuuuuuuuuuu
               vvvvvv wwwwwwwww x yy zzzzzzz.

Thanks     

dseligo:

--- Quote from: JLWest on October 16, 2021, 08:19:16 am ---
--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---         Insert( '|',s2Parse, P1 );             -
--- End quote ---

You have minus ('-') at the end of line 17.

ASerge:
See also [SOLVED] WrapText with indent?
But there is a drawback: in FPC, the WrapText function makes a break after the maximum length (in Delphi before).

JLWest:
@dseligo Thanks
@ ASerge

I don't know how I could use that code.

After fixing the issue I find the parser get's in an endless loop. Can't figure it out.

bytebites:
Variable Lgth is not initialised.

Navigation

[0] Message Index

[#] Next page

Go to full version