home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / STRFST41.ZIP / STRINGS.DOC < prev    next >
Encoding:
Text File  |  1993-01-04  |  4.7 KB  |  134 lines

  1.                               January 23, 1988    
  2.  
  3.  
  4.      This ARC contains two Turbo Pascal Version 4 (TP4) units,
  5. Strings.Pas and Is.Pas.
  6.  
  7. STRINGS.PAS
  8.  
  9.      This is a collection of procedures and functions for string
  10. manipulation (although one is not limited to strings), written
  11. in Inline code for speed.  The unit contains all routines found
  12. in my earlier Strnfst2 collection, rewritten (where necessary)
  13. for TP4, plus some additional ones.  I wrote all but two.  
  14. Mitchell Lazarus wrote FlipChar and StripChar.  
  15.  
  16.      The routines are briefly documented in the Interface
  17. section.  I duplicate here the entries for the routines not
  18. included in Strnfst2:
  19.  
  20.  
  21. Function space (N:integer; C:char):string;
  22.  
  23.      {Returns string of length N, consisting of
  24.       N instances of C
  25.      }
  26.  
  27. Procedure Blanker(var tline:string);
  28.  
  29.    {if tline consists entirely of blanks, sets
  30.     length(tline) to zero.  Otherwise, does not
  31.     alter tline
  32.    }
  33.  
  34. Function Break (search: string; var tline): byte;
  35.  
  36.  {returns position of first occurence in string tline of
  37.   a character in search.  If none is found in tline, returns 0
  38.  }
  39.  
  40. Function Break2 (search,tline:string):byte;
  41.  
  42.   {does exactly what Break does, but by a different method.
  43.    Which is faster probably depends on relative lengths of
  44.    search and tline.
  45.   }
  46.  
  47. Function Span(search,tline:string):byte;
  48.  
  49.   {returns length of initial segment of tline that consists
  50.    entirely of characters found in search.  Assuming there are
  51.    some characters in tline not in search, the first one
  52.    is at tline[span(search,tline) +1]
  53.   }
  54.  
  55. Function LastPosC (find: char; var tst): integer;
  56.  
  57.   {returns position in string tst of last instance of find
  58.   }
  59.  
  60. Function WildPosAfter(find:string; var tline ; after:integer):integer;
  61.  
  62.    {Like PosAfter, but with a wildcard.  Returns position of first
  63.     instance of find in tline, except that ASCII 255 in find matches
  64.     any character in tline.  Thus 'c'#255't' matches cat, cot,
  65.     cut.
  66.    }
  67.  
  68. I don't write ASM well, so many of these routines could be better 
  69. written.  But they seem to work, and, because they are in Inline, 
  70. they are generally much faster than equivalent routines in 
  71. straight TPascal.
  72.  
  73. You could eliminate a lot of these routines without losing any 
  74. capabilities, but with some loss in speed and convenience.  I 
  75. find it convenient to have them all around, but you may not.
  76.  
  77.  
  78. IS.PAS
  79.  
  80.      This unit contains a few well-known character classification 
  81. "functions" written as Inline directives:  IsDigit, IsLower, 
  82. IsUpper, IsAlpha, and IsAlNum.  (You can reorganize the file as 
  83. an include file without affecting much of anything.)
  84.  
  85.      Borland says Inline directives are intended for procedures 
  86. and functions of less than ten bytes.  These are bigger.  
  87. Presumably Borland's reason is that the actual code gets written 
  88. into the EXE file, so you can get the same group of bytes written 
  89. into the file many times, where a real function would be included 
  90. only once, and an additional few bytes to call it each time it is 
  91. used.  So you pay a price in program size for the speed of Inline 
  92. directives.  You could save space (and lose speed) by embedding 
  93. each of these routines in a function shell, like this: 
  94.  
  95.      Function IsAnUpper(c:char):boolean;
  96.       begin
  97.        IsAnUpper := IsUpper(c);
  98.       end;
  99.  
  100. But this is not an ideal solution.  In fact, if you are going
  101. to have actual functions, you would do just about as well (and 
  102. sometimes better) by replacing the "is" routines in the functions
  103. by boolean tests.  My "is" functions run at about the same speed 
  104. as boolean tests.
  105.  
  106.  
  107. -----------------------------------------------------------------
  108.  
  109.      You are free to use the code in this ARC file for any 
  110. purpose whatsoever.  But that code is provided to you without 
  111. warranty of any kind.  Use it at your own risk. 
  112.  
  113.      If you find these procedures and functions useful, or if you 
  114. have any comments, suggestions, or complaints, I would appreciate 
  115. your letting me know  You can write to me at the address given at 
  116. the end of this file, or you can leave a message on Robert 
  117. Blacher's bulletin board, 202/547-2008.
  118.  
  119.      These routines exist only because Dave Baldwin wrote, and 
  120. freely distributed, his INLINE assembler.  If you find them so 
  121. useful that you are moved to send an appropriate contribution, I 
  122. recommend that you send it to Baldwin, and not to me.  I believe 
  123. he uses the following two addresses:
  124.  
  125. 22 Fox Den Rd., (Summer)     144 13th St. East,  (Winter) 
  126. Hollis, NH 03049             Tierra Verde, FL 33715   
  127.  
  128.  
  129.                               David Seidman
  130.                               2737 Devonshire Pl NW
  131.                               Washington, DC 20008
  132.  
  133.  
  134.