I have a text file with key value pairs like this
user1|password1
user2|password2
user3|password3
In delphi 10 I use this function to get the key value
function getKeyByName(fileName, key: string) : string;
var
dataFile : TStringList;
begin
Result := 'Not Found';
dataFile := TStringList.Create;
dataFile.LoadFromFile(fileName);
dataFile.NameValueSeparator := '|';
if dataFile.Values[key] <> '' then
Result := dataFile.Values[key];
dataFile.Free;
end;
For now every thing is worked fine.
I try to use this function with delphi 5, but the property (NameValueSeparator) is not exists.
If I change the separator to (=) and the function to:
function getKeyByName(fileName, key: string) : string;
var
dataFile : TStringList;
begin
Result := 'Not Found';
dataFile := TStringList.Create;
dataFile.LoadFromFile(fileName);
if dataFile.Values[key] <> '' then
Result := dataFile.Values[key];
dataFile.Free;
end;
I can get the result, but the separator in my text file is (|).
What should I do to set the separator char (|) for the list?
Thanks for help.