home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / CPM / LANGUAGS / MODULA2 / STRLIB.DEF < prev    next >
Text File  |  2000-06-30  |  4KB  |  92 lines

  1.  
  2.  
  3. (************************************************************************)
  4. (*                                                                      *)
  5. (*       Requires MRI Modula2                                           *)
  6. (*                                                                      *)
  7. (*       Strlib:                                                        *)
  8. (*               Library module to handle strings.  Included is         *)
  9. (*               terminal I/O, string length, assignment, conc-         *)
  10. (*               atention, insertion, deletion, alteration and          *)
  11. (*               the ability to select portions of a string.            *)
  12. (*                                                                      *)
  13. (*       Verson :                                                       *)
  14. (*               1.0 ; November 16, 83 ;   Namir C. Shammas             *)
  15. (*               1.1 ; November 21, 84 ;   Walter Maner                 *)
  16. (*                                                                      *)
  17. (************************************************************************)
  18.  
  19.  
  20. DEFINITION MODULE Strlib;
  21.  
  22.  EXPORT QUALIFIED Len,StringIs,ShowString,StringAdd,StringDelete,StringPos,
  23.                   StringLeft,StringRight,StringMid,StringRemove,StringInsert,
  24.                   StringReplace,StringChange,StringAlter,InputString,eos;
  25.  
  26. CONST
  27. (*  End Of String  *)
  28.     eos = 0C;
  29.  
  30. PROCEDURE Len(Str : ARRAY OF CHAR):CARDINAL;
  31. (*    Obtain the number of characters in a string.  *)
  32.  
  33. PROCEDURE StringIs (VAR Str1 : ARRAY OF CHAR; Str2 : ARRAY OF CHAR);
  34. (*    Assign an array of characters appended by an eos.  *)
  35.  
  36. PROCEDURE ShowString(Str : ARRAY OF CHAR );
  37. (*    Display the string    *)
  38.  
  39. PROCEDURE StringAdd (VAR Str1 : ARRAY OF CHAR; Str2 : ARRAY OF CHAR );
  40. (*    Concatenate string Str2 to Str1  *)
  41.  
  42. PROCEDURE StringDelete(VAR Str : ARRAY OF CHAR ; First,Last : CARDINAL);
  43. (*    Delete a portion of a string STARTING at 'Fisrt' and ENDING at
  44.       'Last' (included)  *)
  45.  
  46. PROCEDURE StringPos(Str1,Str2 : ARRAY OF CHAR ; Start : CARDINAL):CARDINAL;
  47. (*    Function that returns the position of 'sub-string' Str2 in string 
  48.       Str1. The search begins at position 'Start'.   *)
  49.  
  50. PROCEDURE StringLeft(VAR Str1 : ARRAY OF CHAR ;
  51.                          Str2 : ARRAY OF CHAR; Count : CARDINAL);
  52. (*    Pick the 'Count' leftmost characters of string Str2 and store it in
  53.       string Str1.    *)
  54.  
  55. PROCEDURE StringRight(VAR Str1 : ARRAY OF CHAR ;
  56.                           Str2 : ARRAY OF CHAR;  Count : CARDINAL);
  57. (*    Pick the 'Count' rightmost characters of string Str2 and store it in
  58.       string Str1.    *)
  59.  
  60. PROCEDURE StringMid(VAR Str1 : ARRAY OF CHAR ;
  61.                         Str2 : ARRAY OF CHAR;  Start, Count : CARDINAL);
  62. (*    Pick 'Count' characters starting at position 'Start' in string 
  63.       Str2 and store it in string Str1.   *)
  64.  
  65. PROCEDURE StringRemove(VAR Str1 : ARRAY OF CHAR; Str2 : ARRAY OF CHAR);
  66. (*    Remove ALL occurences of sub-string Str2 in string Str1 and update
  67.       the latter string .   *)
  68.  
  69. PROCEDURE StringInsert(VAR Str1 : ARRAY OF CHAR; Str2 : ARRAY OF CHAR; 
  70.                           Start : CARDINAL);
  71. (*    Insert sub-string Str2 in string Str1 at position 'Start'.  The
  72.       characters at position 'Start' and above are moved.   *) 
  73.  
  74. PROCEDURE StringReplace(VAR Str1 : ARRAY OF CHAR; Str2,Str3 : ARRAY OF CHAR);
  75. (*    Replace ALL occurences of sub-string Str2 with sub-string Str3 in the
  76.       string Str1.   *)
  77.  
  78. PROCEDURE StringChange(VAR Str1 : ARRAY OF CHAR; Str2,Str3 : ARRAY OF CHAR;
  79.                            Start,Repeat:CARDINAL);
  80. (*    Replace 'Repeat' times the occurence of sub-string Str2 by Str3 in
  81.       string Str1.  The action taken starts at position 'Start'.   *)
  82.  
  83. PROCEDURE StringAlter(VAR Str1 : ARRAY OF CHAR; Str2 : ARRAY OF CHAR; 
  84.                                 Start : CARDINAL);
  85. (*    This procedure overwrites the portions of string Str1 starting at
  86.       position 'Start' and for the length of sub-string Str2.  *)
  87.  
  88. PROCEDURE InputString (VAR Str : ARRAY OF CHAR);
  89. (*    Read string from ketboard.  *)
  90.  
  91. END Strlib.
  92.