home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!think.com!spool.mu.edu!darwin.sura.net!lhc!adm!news
- From: Paul.Robinson@f417.n109.z1.fidonet.org (Paul Robinson)
- Newsgroups: comp.lang.pascal
- Subject: String Package (1/4)
- Message-ID: <34187@adm.brl.mil>
- Date: 21 Nov 92 17:21:32 GMT
- Sender: news@adm.brl.mil
- Lines: 116
-
- The following is a string processing package for Pascal, in 4 parts;
- this is
-
- part 1.
-
-
-
- --- Cut here ---
-
-
-
- (* Permission is hereby granted to republish,
-
- * but not for profit, any or all of this program,
-
- * provided that this copyright notice is included.
-
- *
-
- * Copyright 1979, Oregon Software, Inc.
-
- * 2340 SW Canyon Road
-
- * Portland, Oregon 97201
-
- * (503) 226-7760
-
- *)
-
-
-
- {
-
- Strings are stored as a record structure with a fixed
-
- maximum number of characters (normally 100 but easily
-
- changeable), and an integer marking the current length of
-
- the string.
-
-
-
- type String = record
-
- Len: Integer;
-
- Ch: array[1..StringMax] of Char
-
- end
-
-
-
- The capabilities provided are:
-
-
-
- Len(S) - a function giving the current length of string S;
-
-
-
- Clear(S) - initializes string S to empty;
-
-
-
- ReadString(F,S) - reads a value for string S from the text
-
- file F. The string is terminated by Eoln(F) and a
-
- Readln(F) is performed. String overflow (a string longer
-
- than StringMax) results in truncation.
-
-
-
- WriteString(F,S) - writes the string S to the text file F.
-
- This function can also be performed by
-
- Write(F,S.Ch:S.Len).
-
-
-
- Concatenate(T,S) - appends string S to the target string T.
-
- The resulting value is string T. Overflow results in
-
- truncation to StringMax characters.
-
-
-
- Search(S,T,Start) - searchs string S for the first
-
- occurrence of string T to the right of position Start
-
- (characters are numbered beginning with one). The
-
- function Search() returns the position of the first
-
- character in the matching substring, or the value zero if
-
- the string T does not appear.
-
-
-
- Insert(T,S,Start) - inserts the string S into the target
-
- string T at position Start. Characters are shifted to the
-
- right as necessary. Overflow produces a truncated target
-
- string; a Start position which would produce a string
-
- which was not contiguous has no effect.
-
-
-