ex4.pp 1014 B

12345678910111213141516171819202122232425262728293031323334
  1. program example4;
  2. { This program demonstrates the GetFloatProp function }
  3. {$mode objfpc}
  4. uses rttiobj,typinfo;
  5. Var
  6. O : TMyTestObject;
  7. PI : PPropInfo;
  8. begin
  9. O:=TMyTestObject.Create;
  10. Writeln('Real property : ');
  11. PI:=GetPropInfo(O,'RealField');
  12. Writeln('Value : ',O.RealField);
  13. Writeln('Get (name) : ',GetFloatProp(O,'RealField'));
  14. Writeln('Get (propinfo) : ',GetFloatProp(O,PI));
  15. SetFloatProp(O,'RealField',system.Pi);
  16. Writeln('Set (name,pi) : ',O.RealField);
  17. SetFloatProp(O,PI,exp(1));
  18. Writeln('Set (propinfo,e) : ',O.RealField);
  19. Writeln('Extended property : ');
  20. PI:=GetPropInfo(O,'ExtendedField');
  21. Writeln('Value : ',O.ExtendedField);
  22. Writeln('Get (name) : ',GetFloatProp(O,'ExtendedField'));
  23. Writeln('Get (propinfo) : ',GetFloatProp(O,PI));
  24. SetFloatProp(O,'ExtendedField',system.Pi);
  25. Writeln('Set (name,pi) : ',O.ExtendedField);
  26. SetFloatProp(O,PI,exp(1));
  27. Writeln('Set (propinfo,e) : ',O.ExtendedField);
  28. O.Free;
  29. end.