Einzelnen Beitrag anzeigen

ScharfeMietze

Registriert seit: 5. Mär 2014
165 Beiträge
 
Delphi 10.2 Tokyo Architect
 
#22

AW: Gehen strings als Eigenschaftsnamen? Wenn ja wie?

  Alt 7. Okt 2018, 18:08
Heureka
Delphi-Quellcode:
procedure 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
        SetStrProp(LBotOptions,LPropList[I].Name,sValue);
        Break;
      end;
    end;
  finally
    FreeMem(LPropList);
  end;
end;
funktioniert bei mir. Zusammen mit den Tips das es published sein muss und ein Object.


das
Delphi-Quellcode:
       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)));
müsste ich doch weglassen können wenn ich weiß das Property von LBotOptions identisch ist mit dem sValue(string) .... oder übersehe ich da was?

Ansonsten schon mal Vielen lieben dank!! Das ist/war enorm hilfreich !!!!

Geändert von ScharfeMietze ( 7. Okt 2018 um 18:18 Uhr)
  Mit Zitat antworten Zitat