Einzelnen Beitrag anzeigen

Delphi.Narium

Registriert seit: 27. Nov 2017
2.434 Beiträge
 
Delphi 7 Professional
 
#21

AW: Gehen strings als Eigenschaftsnamen? Wenn ja wie?

  Alt 7. Okt 2018, 17:32
Ich bin einen Kleinen schritt weiter !!
Delphi-Quellcode:
rocedure SetProperty2(sProperty, sValue: string);
var
  LPropList: PPropList;
  LPropCount, I: Integer;
begin
  LPropCount := GetPropList(LBotOptions, LPropList);
  try
  for I := 0 to LPropCount-1 do
    begin
    if LPropList[I].Name = sProperty then
      begin
       ShowMessage(LPropList[I].Name);
       Break
      end;
    end;
  finally
    FreeMem(LPropList);
  end;
end;
Damit finde ich nun die richtige eigenschaft. Nun brauche ich noch den Weg wie ich die Eigenschaft schreibe???? Ich hangel mich hier von ast zu ast ... Wenn jemand dafür noch ein Weg hat wäre das super!
Eigentlich müsste das von oben funktionieren.

Noch ein Versuch:
Delphi-Quellcode:
procedure SetProperty3(ABotOptions : TBotOptions; sProperty, sValue: string);
var
  LPropList: PPropList;
  LPropCount, I: Integer;
begin
  LPropCount := GetPropList(ABotOptions, LPropList);
  try
  for I := 0 to LPropCount-1 do
    begin
    if LPropList[I].Name = sProperty then
      begin
       // Abhängig von Typ in LPropList[I].Kind
       case LPropList[I].Kind of
         tkString : SetStrProp(ABotOptions,LPropList[I].Name,sValue);
         tkInteger : SetInt64Prop(ABotOptions,LPropList[I].Name,StrToInt(sValue));
         tkEnumeration : SetOrdProp(ABotOptions,LPropList[I].Name,Ord(IfThen(LowerCase(sValue) = 'true',true,false)));
       end;
       Break;
      end;
    end;
  finally
    FreeMem(LPropList);
  end;
end;
  Mit Zitat antworten Zitat