Strings.def 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. DEFINITION MODULE Strings;
  2. (*
  3. Module: String manipulations
  4. Author: Ceriel J.H. Jacobs
  5. Version: $Id$
  6. *)
  7. (* Note: truncation of strings may occur if the user does not provide
  8. large enough variables to contain the result of the operation.
  9. *)
  10. (* Strings are of type ARRAY OF CHAR, and their length is the size
  11. of the array, unless a 0-byte occurs in the string to indicate the
  12. end of the string.
  13. *)
  14. PROCEDURE Assign(source: ARRAY OF CHAR; VAR dest: ARRAY OF CHAR);
  15. (* Assign string source to dest
  16. *)
  17. PROCEDURE Insert(substr: ARRAY OF CHAR; VAR str: ARRAY OF CHAR; inx: CARDINAL);
  18. (* Insert the string substr into str, starting at str[inx].
  19. If inx is equal to or greater than Length(str) then substr is appended
  20. to the end of str.
  21. *)
  22. PROCEDURE Delete(VAR str: ARRAY OF CHAR; inx, len: CARDINAL);
  23. (* Delete len characters from str, starting at str[inx].
  24. If inx >= Length(str) then nothing happens.
  25. If there are not len characters to delete, characters to the end of the
  26. string are deleted.
  27. *)
  28. PROCEDURE Pos(substr, str: ARRAY OF CHAR): CARDINAL;
  29. (* Return the index into str of the first occurrence of substr.
  30. Pos returns a value greater than HIGH(str) of no occurrence is found.
  31. *)
  32. PROCEDURE Copy(str: ARRAY OF CHAR;
  33. inx, len: CARDINAL;
  34. VAR result: ARRAY OF CHAR);
  35. (* Copy at most len characters from str into result, starting at str[inx].
  36. *)
  37. PROCEDURE Concat(s1, s2: ARRAY OF CHAR; VAR result: ARRAY OF CHAR);
  38. (* Concatenate two strings.
  39. *)
  40. PROCEDURE Length(str: ARRAY OF CHAR): CARDINAL;
  41. (* Return number of characters in str.
  42. *)
  43. PROCEDURE CompareStr(s1, s2: ARRAY OF CHAR): INTEGER;
  44. (* Compare two strings, return -1 if s1 < s2, 0 if s1 = s2, and 1 if s1 > s2.
  45. *)
  46. END Strings.