From 3f1356f667375268ba34d1217d8eff19379749e5 Mon Sep 17 00:00:00 2001 From: tobigun Date: Mon, 19 Jan 2009 21:54:33 +0000 Subject: Mic settings saved again (broken in revision 912) git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1572 b956fd51-792f-4845-bead-9b4dfca2ff2c --- src/base/UIni.pas | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src/base') diff --git a/src/base/UIni.pas b/src/base/UIni.pas index 3a4d6129..7f25a813 100644 --- a/src/base/UIni.pas +++ b/src/base/UIni.pas @@ -283,17 +283,22 @@ function TIni.ExtractKeyIndex(const Key, Prefix, Suffix: string): integer; var Value: string; Start: integer; + PrefixPos, SuffixPos: integer; begin Result := -1; - if Pos(Prefix, Key) > -1 then - begin - Start := Pos(Prefix, Key) + Length(Prefix); + PrefixPos := Pos(Prefix, Key); + if (PrefixPos <= 0) then + Exit; + SuffixPos := Pos(Suffix, Key); + if (SuffixPos <= 0) then + Exit; - // copy all between prefix and suffix - Value := Copy(Key, Start, Pos(Suffix, Key)-1 - Start); - Result := StrToIntDef(Value, -1); - end; + Start := PrefixPos + Length(Prefix); + + // copy all between prefix and suffix + Value := Copy(Key, Start, SuffixPos - Start); + Result := StrToIntDef(Value, -1); end; (** -- cgit v1.2.3