hedgewars/uUtils.pas
changeset 15897 d7b53d08ad9c
parent 14969 f27f00fabc0d
child 15929 128ace913837
child 15991 4ad8dd66d9d5
--- a/hedgewars/uUtils.pas	Wed Sep 21 06:55:31 2022 +0300
+++ b/hedgewars/uUtils.pas	Fri Sep 23 02:21:21 2022 +0300
@@ -26,6 +26,7 @@
 // returns s with whitespaces (chars <= #32) removed form both ends
 function Trim(s: shortstring) : shortstring;
 
+function CountChar(s : shortstring; c: char) : LongInt;
 procedure SplitBySpace(var a, b: shortstring);
 procedure SplitByChar(var a, b: shortstring; c: char);
 procedure SplitByCharA(var a, b: ansistring; c: char);
@@ -218,6 +219,18 @@
 ExtractFilename:= copy(s, lslash + 1, len);
 end;
 
+function CountChar(s : shortstring; c: char): LongInt;
+var i, res : LongInt;
+begin
+    res:= 0;
+    for i:= 1 to Length(s) do
+    begin
+        if s[i] = c then
+           Inc(res)
+    end;
+    CountChar:= res
+end;
+
 procedure SplitBySpace(var a,b: shortstring);
 begin
 SplitByChar(a,b,' ');