It is indeed a bit confusing and inconsistent. While SetValueFromIndex indeed deletes the entry when Value is blank, it even adds an entry with a blank Name when Index is < 0:
Procedure TStrings.SetValueFromIndex(Index: Integer; const Value: string);
begin
If (Value='') then
Delete(Index)
else
begin
If (Index<0) then
Index:=Add('');
CheckSpecialChars;
Strings[Index]:=GetName(Index)+FNameValueSeparator+Value;
end;
end;
SetValue on the other hand apparently allows blank values for Name
and Value, there is no testing at all:
Procedure TStrings.SetValue(const Name, Value: string);
Var L : longint;
begin
CheckSpecialChars;
L:=IndexOfName(Name);
if L=-1 then
Add (Name+FNameValueSeparator+Value)
else
Strings[L]:=Name+FNameValueSeparator+value;
end;
For a consistent behaviour one would also expect that SetValue calls SetValueFromIndex once the index of Name is retrieved, reducing both code and the probability of inconsistencies.
Added: If this were for Delphi compatibility it should at least be consistent.