| 1 |
(* Strings.def provides a Logitech-3.0 compatible library. |
| 2 |
|
| 3 |
Copyright (C) 2005-2025 Free Software Foundation, Inc. |
| 4 |
Contributed by Gaius Mulley <[email protected]>. |
| 5 |
|
| 6 |
This file is part of GNU Modula-2. |
| 7 |
|
| 8 |
GNU Modula-2 is free software; you can redistribute it and/or modify |
| 9 |
it under the terms of the GNU General Public License as published by |
| 10 |
the Free Software Foundation; either version 3, or (at your option) |
| 11 |
any later version. |
| 12 |
|
| 13 |
GNU Modula-2 is distributed in the hope that it will be useful, but |
| 14 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 |
General Public License for more details. |
| 17 |
|
| 18 |
Under Section 7 of GPL version 3, you are granted additional |
| 19 |
permissions described in the GCC Runtime Library Exception, version |
| 20 |
3.1, as published by the Free Software Foundation. |
| 21 |
|
| 22 |
You should have received a copy of the GNU General Public License and |
| 23 |
a copy of the GCC Runtime Library Exception along with this program; |
| 24 |
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see |
| 25 |
<http://www.gnu.org/licenses/>. *) |
| 26 |
|
| 27 |
DEFINITION MODULE Strings ; |
| 28 |
|
| 29 |
EXPORT QUALIFIED Assign, Insert, Delete, Pos, Copy, ConCat, Length, |
| 30 |
CompareStr ; |
| 31 |
|
| 32 |
(* |
| 33 |
Assign - dest := source. |
| 34 |
*) |
| 35 |
|
| 36 |
PROCEDURE Assign (VAR dest: ARRAY OF CHAR; source: ARRAY OF CHAR) ; |
| 37 |
|
| 38 |
|
| 39 |
(* |
| 40 |
Insert - insert the string, substr, into str at position, index. |
| 41 |
substr, is added to the end of, str, if, index >= length(str) |
| 42 |
*) |
| 43 |
|
| 44 |
PROCEDURE Insert (substr: ARRAY OF CHAR; VAR str: ARRAY OF CHAR; |
| 45 |
index: CARDINAL) ; |
| 46 |
|
| 47 |
|
| 48 |
(* |
| 49 |
Delete - delete len characters from, str, starting at, index. |
| 50 |
*) |
| 51 |
|
| 52 |
PROCEDURE Delete (VAR str: ARRAY OF CHAR; index: CARDINAL; length: CARDINAL) ; |
| 53 |
|
| 54 |
|
| 55 |
(* |
| 56 |
Pos - return the first position of substr in str. |
| 57 |
If substr is not found in str then it returns |
| 58 |
HIGH (str) + 1. |
| 59 |
*) |
| 60 |
|
| 61 |
PROCEDURE Pos (substr, str: ARRAY OF CHAR) : CARDINAL ; |
| 62 |
|
| 63 |
|
| 64 |
(* |
| 65 |
Copy - copy at most, length, characters in, substr, to, str, |
| 66 |
starting at position, index. |
| 67 |
*) |
| 68 |
|
| 69 |
PROCEDURE Copy (str: ARRAY OF CHAR; |
| 70 |
index, length: CARDINAL; VAR result: ARRAY OF CHAR) ; |
| 71 |
|
| 72 |
(* |
| 73 |
ConCat - concatenates two strings, s1, and, s2 |
| 74 |
and places the result into, dest. |
| 75 |
*) |
| 76 |
|
| 77 |
PROCEDURE ConCat (s1, s2: ARRAY OF CHAR; VAR dest: ARRAY OF CHAR) ; |
| 78 |
|
| 79 |
|
| 80 |
(* |
| 81 |
Length - return the length of string, s. |
| 82 |
*) |
| 83 |
|
| 84 |
PROCEDURE Length (s: ARRAY OF CHAR) : CARDINAL ; |
| 85 |
|
| 86 |
|
| 87 |
(* |
| 88 |
CompareStr - compare two strings, left, and, right. |
| 89 |
*) |
| 90 |
|
| 91 |
PROCEDURE CompareStr (left, right: ARRAY OF CHAR) : INTEGER ; |
| 92 |
|
| 93 |
|
| 94 |
END Strings. |