equal
deleted
inserted
replaced
304 end; |
304 end; |
305 end; |
305 end; |
306 |
306 |
307 function GetNextSpeechLine(s: ansistring; ldelim: char; var startFrom: LongInt; out substr: ansistring): boolean; |
307 function GetNextSpeechLine(s: ansistring; ldelim: char; var startFrom: LongInt; out substr: ansistring): boolean; |
308 var p, l, m, r: Integer; |
308 var p, l, m, r: Integer; |
309 newl : boolean; |
309 newl, skip: boolean; |
310 c : char; |
310 c : char; |
311 begin |
311 begin |
312 m:= Length(s); |
312 m:= Length(s); |
313 |
313 |
314 substr:= ''; |
314 substr:= ''; |
323 |
323 |
324 newl:= true; |
324 newl:= true; |
325 |
325 |
326 for p:= max(1, startFrom) to m do |
326 for p:= max(1, startFrom) to m do |
327 begin |
327 begin |
|
328 |
328 inc(r); |
329 inc(r); |
|
330 // read char from source string |
329 c:= s[p]; |
331 c:= s[p]; |
330 |
332 |
331 // strip empty lines, spaces and newlines on beginnings of line |
333 // strip empty lines, spaces and newlines on beginnings of line |
332 if (newl or (p = m)) and ((c = ' ') or (c = ldelim)) then |
334 skip:= ((newl or (p = m)) and ((c = ' ') or (c = ldelim))); |
333 continue; |
335 |
334 |
336 if (not skip) then |
335 newl:= (c = ldelim); |
337 begin |
336 if newl then |
338 newl:= (c = ldelim); |
337 break; |
339 // stop if we went past the end of the line |
338 |
340 if newl then |
339 inc(l); |
341 break; |
340 substr[l]:= c; |
342 |
|
343 // copy current char to output substring |
|
344 inc(l); |
|
345 substr[l]:= c; |
|
346 end; |
|
347 |
341 end; |
348 end; |
342 |
349 |
343 inc(startFrom, r); |
350 inc(startFrom, r); |
344 |
351 |
345 SetLengthA(substr, l); |
352 SetLengthA(substr, l); |