GetObjectProp: Sample from rtl documentation not running lazarus / 21-General ---------------------------------------------------------------------- af0815 · 2023-01-26 10:52 I am searching for information and found samples in the rtl documentation, but i am not able to run the samples Is the sample or my installation broken ? (Yes i know this is not a new fpc installation, but according the major version of the documentation. But the same happens with other fpc's) Code from here https://www.freepascal.org/docs- html/3.2.0/rtl/typinfo/getobjectprop.html Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program example5; { This program demonstrates the GetObjectProp function } {$mode objfpc} uses rttiobj,typinfo; Var  O : TMyTestObject;  PI : PPropInfo;  NO1,NO2 : TNamedObject; begin  O:=TMyTestObject.Create;  NO1:=TNamedObject.Create;  NO1.ObjectName:='First named object';  NO2:=TNamedObject.Create;  NO2.ObjectName:='Second named object';  O.ObjField:=NO1;  Writeln('Object property : ');  PI:=GetPropInfo(O,'ObjField');  Write('Property class     : ');  Writeln(GetObjectPropClass(O,'ObjField').ClassName);  Write('Value            : ');  Writeln((O.ObjField as TNamedObject).ObjectName);  Write('Get (name)         : ');  Writeln((GetObjectProp(O,'ObjField') As TNamedObject).ObjectName);  Write('Get (propinfo)     : ');  Writeln((GetObjectProp(O,PI,TObject) as TNamedObject).ObjectName);  SetObjectProp(O,'ObjField',NO2);  Write('Set (name,NO2)     : ');  Writeln((O.ObjField as TNamedObject).ObjectName);  SetObjectProp(O,PI,NO1);  Write('Set (propinfo,NO1) : ');  Writeln((O.ObjField as TNamedObject).ObjectName);  O.Free;end. FPC 3.2.2 i386-win32-win32/win64 a ) getobjectprop.lpr(7,6) Fatal: Cannot find rttiobj used by getobjectprop of the Project Inspector. If i change the uses to rtti, RttiUtils, typeinfo it compiles a little more b ) getobjectprop.lpr(11,7) Error: Identifier not found "TMyTestObject" QuoteCompile Project, Target: getobjectprop.exe: Exit code 1, Errors: 15, Warnings: 1, Hints: 7 Hint: Start of reading config file X:\xxxx\fpc\bin\i386-win32\fpc.cfg Hint: End of reading config file X:\xxxx\fpc\bin\i386-win32\fpc.cfg Verbose: Free Pascal Compiler version 3.2.2-rrelease_3_2_2-0-g0d122c4953 [2021/11/24] for i386 Verbose: Copyright (c) 1993-2021 by Florian Klaempfl and others Verbose: Target OS: Win32 for i386 Verbose: Compiling getobjectprop.lpr getobjectprop.lpr(8,6) Warning: Unit "Rtti" is experimental getobjectprop.lpr(11,7) Error: Identifier not found "TMyTestObject" getobjectprop.lpr(11,20) Error: Error in type definition getobjectprop.lpr(13,13) Error: Identifier not found "TNamedObject" getobjectprop.lpr(13,25) Error: Error in type definition getobjectprop.lpr(16,6) Error: Identifier not found "TMyTestObject" getobjectprop.lpr(17,8) Error: Identifier not found "TNamedObject" getobjectprop.lpr(18,7) Error: Illegal qualifier getobjectprop.lpr(19,8) Error: Identifier not found "TNamedObject" getobjectprop.lpr(20,7) Error: Illegal qualifier getobjectprop.lpr(21,5) Error: Illegal qualifier getobjectprop.lpr(23,20) Error: Incompatible type for arg no. 1: Got "", expected "TClass" typinfo.pp(1347,10) Hint: Found declaration: GetPropInfo(TClass;const AnsiString):^TPropInfo; typinfo.pp(1341,10) Hint: Found declaration: GetPropInfo(TObject;const AnsiString):^TPropInfo; typinfo.pp(1289,10) Hint: Found declaration: GetPropInfo(PTypeInfo;const AnsiString):^TPropInfo; getobjectprop.lpr(25,31) Error: Incompatible type for arg no. 1: Got "", expected "TClass" typinfo.pp(1983,11) Hint: Found declaration: GetObjectPropClass(TClass;const AnsiString):Class Of TObject; typinfo.pp(1977,10) Hint: Found declaration: GetObjectPropClass(TObject;const AnsiString):Class Of TObject; getobjectprop.lpr(27,14) Error: Illegal qualifier getobjectprop.lpr(27,26) Error: Identifier not found "TNamedObject" getobjectprop.lpr(29,25) Fatal: Syntax error, "." expected but "(" found Verbose: Compilation aborted Verbose: X:\xxxx\fpc\bin\i386-win32\ppc386.exe returned an error exitcode ---------------------------------------------------------------------- Thaddy · 2023-01-26 13:05 See https://gitlab.com/freepascal.org/fpc/documentation/-/issues/13199 which is closed. rttiobj is in the docs, probably as per Florian's remark. ---------------------------------------------------------------------- af0815 · 2023-01-26 13:44 Thaddy, there is more wrong and your issue linked is 13 yrs old and the sample is wrong from start to end. If some units exist anywhere in the doc sources is nice, but the sample is broken, because it reference to not existing code in a standard source install of fpc. And in the sample code is NO HINT where the missing code is. All GetxxxProp samples (for typinfo.pp) looks broken in the same manner in the official documentation. Edit: https://gitlab.com/freepascal.org/fpc/documentation/- /blob/main/examples/typinfex/rttiobj.pp ---------------------------------------------------------------------- PascalDragon · 2023-01-26 20:14 Quote from: af0815 on January 26, 2023, 11:52:39 amI am searching for information and found samples in the rtl documentation, but i am not able to run the samples The samples contained in the documentation are not necessarily meant to be completely usable or even compileable. They simply illustrate the principles of what is documented. ---------------------------------------------------------------------- af0815 · 2023-01-26 21:50 Then it should marked: "THIS SAMPLE IS NOT COMPLETE" look in the source of the docs The main functionality of the sample is in the not shown code. IMHO not a good style.