home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TBTREE.ZIP / STRINGS.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1988-07-25  |  2.3 KB  |  81 lines

  1. (* TBTree13             Copyright (c)  1988            Dean H. Farwell II    *)
  2.  
  3. unit Strings;
  4.  
  5. (*****************************************************************************)
  6. (*                                                                           *)
  7. (*            A D D I T I O N A L  S T R I N G  R O U T I N E S              *)
  8. (*                                                                           *)
  9. (*****************************************************************************)
  10.  
  11.  
  12. (* Although Turbo has some string handling routines, there are many others
  13.    which would prove useful.  Here are but a few.                            *)
  14.  
  15. (* Version Information
  16.  
  17.    Version 1.1 - No Changes
  18.  
  19.    Version 1.2 - No Changes
  20.  
  21.    Version 1.3 - No Changes                                                  *)
  22.  
  23.  
  24.  
  25. (*////////////////////////// I N T E R F A C E //////////////////////////////*)
  26.  
  27.  
  28. interface
  29.  
  30. (* Takes a string and adds up the integer value of each individual byte.
  31.   This total can be used to randomize the string for Hashing, etc.           *)
  32.  
  33. function TotalString(var str : String) : Word;
  34.  
  35.  
  36. (*  This routine returns the last n characters of a  string                  *)
  37.  
  38. procedure EndOfString(var str : String;
  39.                      n : Byte;
  40.                      var resultStr : String);
  41.  
  42. (*\*)
  43. (*///////////////////// I M P L E M E N T A T I O N /////////////////////////*)
  44.  
  45. implementation
  46.  
  47.  
  48. (* Takes a string and adds up the integer value of each individual byte.
  49.    This total can be used to randomize the string for Hashing, etc.          *)
  50.  
  51. function TotalString(var str : String ) : Word;
  52.  
  53. var
  54.     tot : Word;
  55.     cnt : Byte;
  56.  
  57.     begin
  58.     tot := 0;
  59.     for cnt := 1 to Length(str) do
  60.         begin
  61.         tot := tot + Integer(str[cnt]);
  62.         end;
  63.     TotalString := tot;
  64.     end;                                     (* end of Total String Function *)
  65.  
  66.  
  67. (*  This routine returns the last n characters of a  string                    *)
  68.  
  69. procedure EndOfString(var str : String;
  70.                       n : Byte;
  71.                       var resultStr : String);
  72.  
  73.  
  74.     begin
  75.     resultStr := Copy(str,(Length(str) - n + 1),n);
  76.     end;                                       (* end of EndOfString routine *)
  77.  
  78.  
  79. end.                                                  (* end of Strings unit *)
  80.  
  81.