hedgewars/uFLUtils.pas
branchqmlfrontend
changeset 10757 f71275973737
parent 10616 20a2d5e6930a
--- a/hedgewars/uFLUtils.pas	Thu Jan 29 23:36:58 2015 +0300
+++ b/hedgewars/uFLUtils.pas	Mon Feb 02 23:12:56 2015 +0300
@@ -6,6 +6,8 @@
 function strToInt(s: shortstring): LongInt;
 function midStr(s: shortstring; pos: byte): shortstring;
 procedure underScore2Space(var s: shortstring);
+function readInt(name, input: shortstring; var value: LongInt): boolean;
+function readBool(name, input: shortstring; var value: boolean): boolean;
 
 implementation
 
@@ -45,4 +47,34 @@
         if s[i] = '_' then s[i]:= ' '
 end;
 
+function readInt(name, input: shortstring; var value: LongInt): boolean;
+var l: LongInt;
+begin
+    name:= name + '=';
+    l:= length(name);
+
+    if copy(input, 1, l) = name then
+    begin
+        value:= strToInt(midStr(input, l + 1));
+        readInt:= true
+    end
+    else
+        readInt:= false
+end;
+
+function readBool(name, input: shortstring; var value: boolean): boolean;
+var l: LongInt;
+begin
+    name:= name + '=';
+    l:= length(name);
+
+    if copy(input, 1, l) = name then
+    begin
+        value:= (length(input) > l) and (input[l + 1] <> 'f');
+        readBool:= true
+    end
+    else
+        readBool:= false
+end;
+
 end.