home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / pascal / 6799 < prev    next >
Encoding:
Internet Message Format  |  1992-11-21  |  1.4 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!darwin.sura.net!lhc!adm!news
  2. From: Paul.Robinson@f417.n109.z1.fidonet.org (Paul Robinson)
  3. Newsgroups: comp.lang.pascal
  4. Subject: String (2/4)
  5. Message-ID: <34186@adm.brl.mil>
  6. Date: 21 Nov 92 17:21:27 GMT
  7. Sender: news@adm.brl.mil
  8. Lines: 75
  9.  
  10. The Start and Span parameters in the following procedures
  11.  
  12. define a substring beginning at position Start (between
  13.  
  14. characters Start-1 and Start) with a length of Abs(Span).
  15.  
  16. If Span is positive, the substring is to the right of Start;
  17.  
  18. if negative, the substring is to the left.
  19.  
  20.  
  21.  
  22. Delete(S,Start,Span) - deletes the substring defined by
  23.  
  24.   Start, Span from the string S.
  25.  
  26.  
  27.  
  28. Substring(T,S,Start,Span) - the substring of string S
  29.  
  30.   defined by Start, Span is assigned to the target string T.
  31.  
  32. }
  33.  
  34. const   stringmax=100;
  35.  
  36. type    string=record
  37.  
  38.            len: 0..stringmax;
  39.  
  40.            ch: packed array[1..stringmax] of char
  41.  
  42.            end;
  43.  
  44.  
  45.  
  46. function len(VAR s:string):integer;
  47.  
  48. begin   len:= s.len
  49.  
  50. end;
  51.  
  52.  
  53.  
  54. procedure clear(var s:string);
  55.  
  56. var     i: integer;
  57.  
  58. begin   s.len:=0;
  59.  
  60.         for i:=1 to stringmax do s.ch[i]:=' '
  61.  
  62. end;
  63.  
  64.  
  65.  
  66. procedure concatenate(var s:string; VAR t:string);
  67.  
  68. var     i,j: integer;
  69.  
  70. begin
  71.  
  72.         if s.len+t.len>stringmax
  73.  
  74.            then j:=stringmax-s.len { overflow }
  75.  
  76.            else j:=t.len;
  77.  
  78.         for i:=1 to j do s.ch[s.len+i]:=t.ch[i];
  79.  
  80.         s.len:=s.len+j;
  81.  
  82. end;
  83.  
  84.  
  85.