-1

I have Done with a method definition of my properties as get and set(fname,lname,address).I have also done withy propcount but it is throwing a error.so can anyone give me a sample code how should i set properties at runtime. so my question is how can i do it??

  • can you show us any code ? Its hard so say what is wrong with code if we cannot see it – GuidoG Feb 14 '18 at 16:42
  • Possible duplicate of [Get/Set sub properties ussing RTTI](https://stackoverflow.com/questions/7649812/get-set-sub-properties-ussing-rtti) – GuidoG Feb 14 '18 at 16:44

1 Answers1

0

You can use variant data type, it provides a flexible general purpose data type.

// Show the type of a variant
procedure ShowBasicVariantType(varVar: Variant);
var
  typeString : string;
  basicType  : Integer;

begin
  // Get the Variant basic type :
  // this means excluding array or indirection modifiers
  basicType := VarType(varVar) and VarTypeMask;

  // Set a string to match the type
  case basicType of
    varEmpty     : typeString := 'varEmpty';
    varNull      : typeString := 'varNull';
    varInteger   : typeString := 'varInteger';
    varInt64     : typeString := 'varInt64';
    varByte      : typeString := 'varByte';
    varDate      : typeString := 'varDate';
    varString    : typeString := 'varString';
    varAny       : typeString := 'varAny';
  end;

  // Show the Variant type
  writeln('Variant type  = '+typeString);
end;

In the main program :

var
  myVar : variant;
begin
  // Assign various values to a Variant
  // and then show the resulting Variant type
  writeln('Variant value = not yet set');
  ShowBasicVariantType(myVar);

  // Simple value
  myVar := 123;
  writeln('Variant value = 123');
  ShowBasicVariantType(myVar);

  // Calculated value using a Variant and a constant
  myVar := myVar + 456;
  writeln('Variant value = 123 + 456');
  ShowBasicVariantType(myVar);

  myVar := 'String '+IntToStr(myVar);
  writeln('Variant value = String 579');
  ShowBasicVariantType(myVar);

  readln;
end.
Korteby Farouk
  • 629
  • 7
  • 14