home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!darwin.sura.net!lhc!adm!news
- From: Paul.Robinson@f417.n109.z1.fidonet.org (Paul Robinson)
- Newsgroups: comp.lang.pascal
- Subject: String (2/4)
- Message-ID: <34186@adm.brl.mil>
- Date: 21 Nov 92 17:21:27 GMT
- Sender: news@adm.brl.mil
- Lines: 75
-
- The Start and Span parameters in the following procedures
-
- define a substring beginning at position Start (between
-
- characters Start-1 and Start) with a length of Abs(Span).
-
- If Span is positive, the substring is to the right of Start;
-
- if negative, the substring is to the left.
-
-
-
- Delete(S,Start,Span) - deletes the substring defined by
-
- Start, Span from the string S.
-
-
-
- Substring(T,S,Start,Span) - the substring of string S
-
- defined by Start, Span is assigned to the target string T.
-
- }
-
- const stringmax=100;
-
- type string=record
-
- len: 0..stringmax;
-
- ch: packed array[1..stringmax] of char
-
- end;
-
-
-
- function len(VAR s:string):integer;
-
- begin len:= s.len
-
- end;
-
-
-
- procedure clear(var s:string);
-
- var i: integer;
-
- begin s.len:=0;
-
- for i:=1 to stringmax do s.ch[i]:=' '
-
- end;
-
-
-
- procedure concatenate(var s:string; VAR t:string);
-
- var i,j: integer;
-
- begin
-
- if s.len+t.len>stringmax
-
- then j:=stringmax-s.len { overflow }
-
- else j:=t.len;
-
- for i:=1 to j do s.ch[s.len+i]:=t.ch[i];
-
- s.len:=s.len+j;
-
- end;
-
-
-