AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren

Expert Delphi - Code Errata

Ein Thema von DP News-Robot · begonnen am 26. Feb 2019
Antwort Antwort
Benutzerbild von DP News-Robot
DP News-Robot

Registriert seit: 4. Jun 2010
14.951 Beiträge
 
#1

Expert Delphi - Code Errata

  Alt 26. Feb 2019, 04:21
For the past month I have been making my way through Pawel Gloawcki's book Expert Delphi. I love this book. I am having fun and learning so much. I completed the "Game of Memory" application from Chapter 4, and it works pretty good.



I initially ran into an issue running The Game of Memory on my Galaxy S9+. In portrait mode, if I selected "6 Pairs" it rendered two columns of six. However, only the top portion of the bottom two tiles displayed. I changed the TILE_MARGIN constant from 2 to 4 and it fixed the render problem.

I moved onto Chapter 5 - Firemonkey in 3D. I discovered an error from page 162 that took me over an hour to track down. I finally figured it out. The program is supposed to display a red 3D Pyramid. However, I was only getting a blank screen. I discoverd one of the private properties was not getting set.

TWireframe = class(TControl3d)
private
FDrawColor: TAlphaColor;
FEdges: TEdges;
FPoints3D: TPoints3D;
FDisplayed: Boolean;
public
constructor Create(AOwner: TComponent) ; override;
destructor Destroy; override;
procedure Render; override;
property DrawColor: TAlphaColor read FDrawColor write FDrawColor;
property Points3D: TPoints3D read FPoints3D;
property Edges: TEdges read FEdges;
property Displayed: Boolean read FDisplayed write FDisplayed;
end;

It is the code for the constructor where the error is:

The private boolean field FDisplayed was not getting set to true.

constructor TWireframe.Create(AOwner: TComponent);
begin
inherited;
FPoints3D := TPoints3D.Create;
FEdges := TEdges.Create;
FDrawColor := TAlphaColorRec.Red;
end;






As soon as I added this code to the constructor it worked like it was supposed to.

constructor TWireframe.Create(AOwner: TComponent);
begin
inherited;
FPoints3D := TPoints3D.Create;
FEdges := TEdges.Create;
FDrawColor := TAlphaColorRec.Red;
FDisplayed := True; // This is missing on page 162 of the book
end;



It probably wouldn't have taken me so long to figure this out if I was a more seasoned Delphi programmer. Oh well, it is what it is. So, for any of you who are reading or plan to read "Expert Delphi" keep this little tidbit in mind when you get to Chapter 5.

I have submitted an errata to the folks at https://packtpub.com

Enjoy,
Gunny Mike
https://zilchworks.com







Weiterlesen...
  Mit Zitat antworten Zitat
Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 19:20 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz