DIY CODE FOR HANDLING FILES IN 'INI-FILE-FORMAT'
type
TKeyVal = record
key : String;
value : String;
end;
function GetKeyAndValueFromLine(srcLine: String): TKeyVal;
function GetKeyAndValueFromLine(srcLine: String): TKeyVal;
{return the 'key' and 'value' from an input line of the form "key=value".
OK I know there are built-in routines to handle INI files (and we are
talking about data in INI file format here) but the expectation is that
this DIY approach will result in faster code execution...}
const
MaxLineLength = 255;
var
eqPos : Integer;
keyAndValue: TKeyVal;
tmpArray: array[0..MaxLineLength] of Char;
tmpIdx: Integer;
begin
eqPos := Pos('=', srcLine);
if (eqPos > 0) then
begin
for tmpIdx := 0 to eqPos do
begin
tmpArray[tmpIdx] := srcLine[tmpIdx + 1];
if (tmpIdx > MaxLineLength) then break;
end;
tmpArray[eqPos - 1] := #0;
keyAndValue.key := String(tmpArray);
Inc(eqPos);
keyAndValue.value := Copy(srcLine, eqPos, Length(srcLine));
end
else
begin
keyAndValue.key := '';
keyAndValue.value := '';
end;
Result := keyAndValue;
end;