Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2016-01

Documentation example error

9 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Graeme Geldenhuys

Hi,

I was always under the impression that the examples included in the FPC documentation should be compilable examples.

Looking at the following example code included with the GenEnumName() documentation, it will not compile because TMyTestObject is undefined.

http://www.freepascal.org/docs-html/rtl/typinfo/getenumname.html

If my assumption about compilable examples are correct, I'll be happy to supply a patch to fix it.

Regards,
- Graeme -

My public PGP key: http://tinyurl.com/graeme-pgp

Michael Van Canneyt
to Graeme Geldenhuys
Graeme Geldenhuys wrote 13 lines
Hi, I was always under the impression that the examples included in the FPC documentation should be compilable examples. Looking at the following example code included with the GenEnumName() documentation, it will not compile because TMyTestObject is undefined. http://www.freepascal.org/docs-html/rtl/typinfo/getenumname.html If my assumption about compilable examples are correct, I'll be happy to supply a patch to fix it.

They should definitely be compilable.

I do not check this regularly, though :/

Michael.

Stephen Chrzanowski
to Michael Van Canneyt

I looked at the example, and it isn't compilable by my eye ball, however, the idea I think is to replace that not found class def'n with something you already know about. You could possibly just replace it with a tedit or tlistbox or something.

On Mon, Jan 25, 2016 at 11:32 AM, Michael Van Canneyt <

Show quoted text 32 lines
wrote: On Mon, 25 Jan 2016, Graeme Geldenhuys wrote: Hi, > > I was always under the impression that the examples included in the FPC > documentation should be compilable examples. > > Looking at the following example code included with the GenEnumName() > documentation, it will not compile because TMyTestObject is undefined. > > http://www.freepascal.org/docs-html/rtl/typinfo/getenumname.html > > > If my assumption about compilable examples are correct, I'll be happy to > supply a patch to fix it. > They should definitely be compilable. I do not check this regularly, though :/ Michael. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Graeme Geldenhuys
to Stephen Chrzanowski: I looked at the example, and it isn't compilable by my eye ball, however, the idea I…
Stephen Chrzanowski wrote
You could possibly just replace it with a tedit or tlistbox or something.

No, that would make the example GUI and GUI Toolkit dependant. Free Pascal doesn't include any GUI dependencies.

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp
Graeme Geldenhuys
to Michael Van Canneyt: They should definitely be compilable. I do not check this regularly, though :/ Michael.
Michael Van Canneyt wrote
They should definitely be compilable.

To make the typeinfex/*.pp examples compilable, I had to make some changes as shown below. I don't hope text wrapping screws this up, but just in case, I attached the patch too. Before, it seems it was valid to typecast a Set as Integer(), but testing with FPC 3.0 it seems typecasting as Byte() is now required.

If I don't, the compile gives the following error:

   ex8.pp(25,17) Error: Illegal type conversion: "LongInt" to "TMyEnums"

Do you know when this change was made in FPC, and where it is documented (eg: wiki User Changes ...)?

====================================
[typinfex (master)]$ git diff ex8.pp
diff --git a/typinfex/ex8.pp b/typinfex/ex8.pp
index 1a9d71e..e0c720c 100644
--- a/typinfex/ex8.pp
+++ b/typinfex/ex8.pp
@@ -20,9 +20,9 @@ begin
   O:=TMyTestObject.Create;
   O.SetField:=[mefirst,meSecond,meThird];
   PI:=GetPropInfo(O,'SetField');
-  Writeln('SetToString (brackets) :
',SetToString(Pi,Integer(O.SetField),True));
-  Writeln('SetToString (default)  : ',SetToString(Pi,Integer(O.SetField)));
-  O.SetField:=TMyEnums(StringToSet(PI,ConstSet));
-  Writeln('Stringtoset            : ',SetToString(PI,Integer(O.SetField)));
+  Writeln('SetToString (brackets) :
',SetToString(Pi,Byte(O.SetField),True));
+  Writeln('SetToString (default)  : ',SetToString(Pi,Byte(O.SetField)));
+  O.SetField := TMyEnums(Byte(StringToSet(PI,ConstSet)));
+  Writeln('StringToSet            : ',SetToString(PI,Byte(O.SetField)));
   O.Free;
 end.
====================================

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp
Jonas Maebe
to Graeme Geldenhuys: To make the typeinfex/*.pp examples compilable, I had to make some changes as shown…

Graeme Geldenhuys wrote on Tue, 26 Jan 2016:

Show quoted text 12 lines
To make the typeinfex/*.pp examples compilable, I had to make some changes as shown below. I don't hope text wrapping screws this up, but just in case, I attached the patch too. Before, it seems it was valid to typecast a Set as Integer(), but testing with FPC 3.0 it seems typecasting as Byte() is now required. If I don't, the compile gives the following error: ex8.pp(25,17) Error: Illegal type conversion: "LongInt" to "TMyEnums" Do you know when this change was made in FPC, and where it is documented (eg: wiki User Changes ...)?

The rttiobj unit is compiled in Delphi mode, hence http://wiki.freepascal.org/User_Changes_2.6.0#Sizes_of_sets_in_TP.2FDelphi_mode

Jonas