bazzer747 25 Posted December 14, 2022 Hi When I use a Firedac TFDConnection I normally rename it from the given (FDConnection1) name to something like 'fdc', I usually rename components to be the same amongst all my projects. However, when I did this on my latest project I cannot use something like: fdc.Connected:= True; I get an 'undeclared identifier: 'Connected'' error when compiling'. I rename it back to 'FDConnection1' and 'FDConnection1.Connected:= True;' compiles fine. Any thoughts as to why this might be? Share this post Link to post
Lajos Juhász 293 Posted December 14, 2022 you have a local variable fdc. Try self.fdc.Connected:= True; Share this post Link to post
bazzer747 25 Posted December 14, 2022 self.fdc.connected works! Got it! The procedure I use for this code is called procedure ConnectLiveTest( fdc: String ); So that is the 'local variable'! I renamed it to procedure ConnectLiveTest( svr: String ); And can now use fdc.connected:= True; as I want to. Thanks for the info. Share this post Link to post
programmerdelphi2k 237 Posted December 14, 2022 (edited) Tip 1: Don't skimp on letters when naming things! be explicit! Tip 2: Do not exaggerate! everything has a limit! In Delphi, 31 chars it's ok for names! but you can use so much more these days! Edited December 14, 2022 by programmerdelphi2k Share this post Link to post
bazzer747 25 Posted December 15, 2022 Hi On the subject of not skimping on names, I see too many code examples where the length of variables are unnecessarily way to long. I always create my variables to as short as possible, making sure they tell me something about what type they are and what they are used for. Makes code easier to read and understand. Most I use are local to the procedure, and any unit wide or global (very few and resisted) are named appropriately. Share this post Link to post
programmerdelphi2k 237 Posted December 15, 2022 (edited) each one with your solutions, not? what is better for a team? iTot : integer; // ref to total of object of class TButtons or LButtonCounting:integer; or fdc:string; fdc:FDConnection; Edited December 15, 2022 by programmerdelphi2k Share this post Link to post
bazzer747 25 Posted December 15, 2022 Whichever tells me enough about it's purpose (or the teams, if a team is involved). I often will write copious comments explaining what might be complex code. Share this post Link to post