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

  1. Path: sparky!uunet!think.com!spool.mu.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 Package (1/4)
  5. Message-ID: <34187@adm.brl.mil>
  6. Date: 21 Nov 92 17:21:32 GMT
  7. Sender: news@adm.brl.mil
  8. Lines: 116
  9.  
  10. The following is a string processing package for Pascal, in 4 parts;  
  11. this is
  12.  
  13. part 1.
  14.  
  15.  
  16.  
  17. --- Cut here ---
  18.  
  19.  
  20.  
  21. (*      Permission is hereby granted to republish,
  22.  
  23.  *      but not for profit, any or all of this program,
  24.  
  25.  *      provided that this copyright notice is included.
  26.  
  27.  *
  28.  
  29.  *      Copyright 1979, Oregon Software, Inc.
  30.  
  31.  *                      2340 SW Canyon Road
  32.  
  33.  *                      Portland, Oregon 97201
  34.  
  35.  *                      (503) 226-7760
  36.  
  37.  *)
  38.  
  39.  
  40.  
  41. {
  42.  
  43. Strings are stored as a record structure with a fixed
  44.  
  45. maximum number of characters (normally 100 but easily
  46.  
  47. changeable), and an integer marking the current length of
  48.  
  49. the string.
  50.  
  51.  
  52.  
  53.     type String = record
  54.  
  55.            Len: Integer;
  56.  
  57.            Ch:  array[1..StringMax] of Char
  58.  
  59.            end
  60.  
  61.  
  62.  
  63. The capabilities provided are:
  64.  
  65.  
  66.  
  67. Len(S) - a function giving the current length of string S;
  68.  
  69.  
  70.  
  71. Clear(S) - initializes string S to empty;
  72.  
  73.  
  74.  
  75. ReadString(F,S) - reads a value for string S from the text
  76.  
  77.   file F.  The string is terminated by Eoln(F) and a
  78.  
  79.   Readln(F) is performed.  String overflow (a string longer
  80.  
  81.   than StringMax) results in truncation.
  82.  
  83.  
  84.  
  85. WriteString(F,S) - writes the string S to the text file F.
  86.  
  87.   This function can also be performed by
  88.  
  89.   Write(F,S.Ch:S.Len).
  90.  
  91.  
  92.  
  93. Concatenate(T,S) - appends string S to the target string T.
  94.  
  95.   The resulting value is string T.  Overflow results in
  96.  
  97.   truncation to StringMax characters.
  98.  
  99.  
  100.  
  101. Search(S,T,Start) - searchs string S for the first
  102.  
  103.   occurrence of string T to the right of position Start
  104.  
  105.   (characters are numbered beginning with one).  The
  106.  
  107.   function Search() returns the position of the first
  108.  
  109.   character in the matching substring, or the value zero if
  110.  
  111.   the string T does not appear.
  112.  
  113.  
  114.  
  115. Insert(T,S,Start) - inserts the string S into the target
  116.  
  117.   string T at position Start.  Characters are shifted to the
  118.  
  119.   right as necessary.  Overflow produces a truncated target
  120.  
  121.   string;  a Start position which would produce a string
  122.  
  123.   which was not contiguous has no effect.
  124.  
  125.  
  126.