unit strings; { String handling primitives. } { These should be recoded in C instead of using the p2c code. } interface procedure scan1 (s: string; p: integer; var n: integer); { Read an integer at position p of s } function startsWith (s1, s2: string): boolean; function pos1(c: char; s: string): integer; function posNot (c: char; var s: string): integer; procedure insertChar (c: char; var s: string; p: integer); function substr (var s: string; start, count: integer): string; procedure getNum(line: string; var k: integer); procedure getTwoNums(var line: string; var k1, k2: integer); procedure toUpper(var s: string); procedure delete1 (var s: string; p: integer); procedure predelete (var s: string; l: integer); procedure shorten (var s: string; new_length: integer); function nextWordBound(s: string; trigger: char; p: integer): integer; { find end of first word starting with trigger after s[p] } implementation procedure scan1 (s: string; p: integer; var n: integer); begin if length(s)

c then begin posnot:=i; exit; end; posnot:=0; end; procedure strval(line: string; var num, p: integer); begin val(line,num,p); end; procedure getNum(line: string; var k: integer); var code: integer; begin strval(line,k,code); if code>0 then strval(copy(line,1,code-1),k,code); end; procedure getTwoNums(var line: string; var k1, k2: integer); var num, code, p: integer; begin strval(line,num,p); strval(copy(line,1,p-1),k1,code); strval(copy(line,p+1,255),k2,code); if code>0 then strval(copy(line,1,code-1),k2,code); end; procedure toUpper (var s: string); var i: integer; begin for i:=1 to length(s) do s[i]:=upcase(s[i]); end; function startsWith (s1, s2: string): boolean; var i, l1, l2: integer; begin l1:=length(s1); l2:=length(s2); startsWith := false; if l1s2[i] then exit; startsWith := true; end; procedure insertChar (c: char; var s: string; p: integer); begin if length(s)length(s)) or (s[p]=trigger); while (p' ') do p:=p+1; nextWordBound:=p; end; end.