

david_navigator
Members-
Content Count
29 -
Joined
-
Last visited
Community Reputation
0 NeutralRecent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
-
Compiler doesn't issue warning - do any third part code analysis tools ?
david_navigator replied to david_navigator's topic in General Help
Thanks.... and had I declared it as a Word, then the compiler would have picked up that I'd accidentally added an extra zero in to the default value (160000, rather than 16000) and I wouldn't have needed to debug and thus create my own bug !!! -
Compiler doesn't issue warning - do any third part code analysis tools ?
david_navigator posted a topic in General Help
I just discovered a nasty bug in my code. During a previous debugging session I'd commented out the use of a parameter and replaced it with a hardcoded value i.e aPort replaced with 16000 procedure TAPI_Handler.ConnectDatabase(const aIPaddress: string = '192.168.42.212'; const aPort: Integer = 160000); ... ... ... FnxWinsockTransport.Port := 16000; // aPort; Surprisingly the compiler doesn't issue a hint or a warning that aPort isn't used, neither does Pascal Analyzer. Does anyone know of any third party code checking tool (maybe TMS ?) that would have picked this up ? Cheers David -
Range Check Error - what actually happens
david_navigator replied to david_navigator's topic in Algorithms, Data Structures and Class Design
8 different types. -
Range Check Error - what actually happens
david_navigator replied to david_navigator's topic in Algorithms, Data Structures and Class Design
Quickly Grepping the source, it looks like there are 8 independent sets that use the GetSetCardinality function. -
Range Check Error - what actually happens
david_navigator replied to david_navigator's topic in Algorithms, Data Structures and Class Design
Brilliant. Thank you very much. Saved me hours of googling & head scratching 🙂 Happy New Year. -
Range Check Error - what actually happens
david_navigator replied to david_navigator's topic in Algorithms, Data Structures and Class Design
I think I might need some help here then. The colleague that wrote this function is on furlough for at least the next four months due to Covid, so I have to address the problematic code myself and I'm not sure I understand why it's done like this to be able to refactor it correctly. The function is passed a set along with the sizeof(the set) This is the original function (with the array of bytes set at the original wrong value of 8 bytes, rather than I believe the correct value of 32 bytes) function GetSetCardinality(const aSet; aLen: Word): Word; { Sample call would be: count := GetSetCardinality(SomeSet, sizeof(SomeSet)); } var B, i: Integer; abyte: Byte; bytes: array [0 .. 7] of Byte absolute aSet; begin result := 0; for B := 0 to aLen - 1 do begin abyte := bytes[B]; for i := 0 to 7 do if (abyte and (1 shl i)) <> 0 then Inc(result); end; end; -
Range Check Error - what actually happens
david_navigator replied to david_navigator's topic in Algorithms, Data Structures and Class Design
Thanks for the replies. The programmer's comment above the code indicates that the function is supposed to return the number of elements in a set. If I'm not mistaken I believe delphi allows up to 256 elements which are represented as 256 bits (rather than encoded in to 8 bytes), which I assume means that bytes: array [0 .. 7] of Byte absolute aSet; should actually be bytes: array [0 .. 31] of Byte absolute aSet; The rest of the code simply counts the number of bits set in each abyte which it returns as the result. -
Range Check Error - what actually happens
david_navigator posted a topic in Algorithms, Data Structures and Class Design
I just compiled a colleagues code with Range checking turned on and got an immediate error. It's fairly obvious why and an easy fix (aLen had a value of 9 in this circumstance and the bytes array is simply the wrong size), but I was wondering what actually happens when the faulty code is executing with range checking turned OFF ? What actually happens when the line abyte := bytes[B]; is executed with a value of 8 for B ? Is there a potential for memory corruption or does the code internally fail gracefully ? function GetSetCardinality(const aSet; aLen: Word): Word; var B, i: Integer; abyte: Byte; bytes: array [0 .. 7] of Byte absolute aSet; begin result := 0; for B := 0 to aLen - 1 do begin abyte := bytes[B]; ... ... Many thanks Cheers David -
Delphi 10.4 unusably slow.
david_navigator replied to david_navigator's topic in Delphi IDE and APIs
@Stano this is 10.4.1 with latest patches. I keep forgetting to call it 10.4.1 rather than just 10.4 @Uwe Raabe it's a Virtual machine, but it thinks that it's 2 processors of 1 core each. The real machine is i7 4 core. Very weirdly. Atter two and a half hours it suddenly started working correctly. D10.1 had no issues, so I don't think it was Windows doing something. Currently seems to be OK - fingers crossed it continues that way. -
Just upgraded to D10.4 but it's unusable. The editor has a 2 second delay & now 27 mins after loading a project, the IDE is still chugging along doing something. Tried a Windows reboot. Also look at memory footprint compared to 10.1 for the same project. <Later> Very weird, even with a simple "Hello World" app delphi is using 43% processor. I'm guessing this is some badly behaved design time package. Is there anyway to diagnose, other than removing them one by one (very, very laborious) ?
-
I'm not really using it as a library of reusable code, more a reminder of how to do things e.g I can never remember how to iterate through the nodes of an XML document - something I might need to code every couple of years, so I just want to be able to pull up an example bit of code to refresh my memory.
-
What do others do to keep track of their useful code snippits ? I use Gexperts Code Librarian but I'm finding the inability to import and export folders and snippets a bit restrictive, plus I believe I can't open the same librarian file in two different IDE's at the same time. Other than that, it does do everything I need. Are there alternatives ?
-
Upgraded and all working now 🙂
-
Been using Delphi since day 1 of D1 and only found this site a few weeks ago. Is there a reason that it's not indexed by Google ?
-
Thanks. Nothing on the update page - maybe because I installed from ISO rather than Web ? Found download on https://my.embarcadero.com/ - thanks (of course how was I supposed to know that even existed !!)