-
Content Count
3710 -
Joined
-
Last visited
-
Days Won
185
Everything posted by David Heffernan
-
'Floating point division by zero' when running script
David Heffernan replied to a topic in Python4Delphi
This is just going to be the age old issue that most Windows code expects floating point exceptions to be masked, and Delphi's RTL unmasks them. So, mask floating point exceptions when you call into Python, and unmask them when the Python call returns. Or just mask them always if you don't care about floating point exceptions. Of course, the floating point support for changing floating point control state is not thread safe in the Delphi RTL as I have been saying for more than a decade now. -
It still doesn't make any sense to me why you wouldn't just use TStopwatch.
-
No idea why you wouldn't use TStopwatch
-
stringreplace character in all string
David Heffernan replied to William23668's topic in RTL and Delphi Object Pascal
I'm sure your function would give the same result. Did you read the earlier posts? They explain what is going on. -
stringreplace character in all string
David Heffernan replied to William23668's topic in RTL and Delphi Object Pascal
Why is that better than StringReplace? How does it relate to the problem in this thread? -
Move a Function or Procedure to a Unit??
David Heffernan replied to Ian Branch's topic in General Help
Get Martin Fowler's book on refactoring. -
Fair enough. Let's just switch to PHP then and be done with it. Bruh.
-
Nothing there is useful. Hard to get past the basic sin of treating a string as if it were a byte array.
-
It doesn't much matter what the thing is that you encrypt. What matters is who encrypts it, and who has knowledge of the key or keys used to encrypt and decrypt. That's what I mean by usage. As for how you do it, convert the text to binary using a well defined encoding, e.g. UTF8, and encrypt that. Encryption algorithms work with binary data not text.
-
It depends on what your usage is
-
Your Delphi verion does not support COMMAND
David Heffernan replied to TimCruise's topic in Python4Delphi
Pro has command line compiler -
Answer found in the code which we can't see.
-
Save the file to a directory where you have write permission
-
stringreplace character in all string
David Heffernan replied to William23668's topic in RTL and Delphi Object Pascal
Also, this isn't how to display binary in a hex editor. -
stringreplace character in all string
David Heffernan replied to William23668's topic in RTL and Delphi Object Pascal
Big lesson here is always to show a proper minimal but complete reproduction. It wasn't clear what the problem was from the first post which was descriptive. Code doesn't lie. -
stringreplace character in all string
David Heffernan replied to William23668's topic in RTL and Delphi Object Pascal
Should be #0 rather than '#0'. Your code is replacing the text '#0' which doesn't appear in the string. -
stringreplace character in all string
David Heffernan replied to William23668's topic in RTL and Delphi Object Pascal
Can you show what the output of your code is. It should be easy to produce a minimal complete program, a console app, that demonstrates the behaviour that you are struggling with. -
Reading a binary file hangup without error
David Heffernan replied to William23668's topic in RTL and Delphi Object Pascal
But it's not text, you can't treat it as text, and there's nothing to learn. What you should learn is how text is encoded. Why not do that? -
Opinions about Pascal vs C/C++ IDE
David Heffernan replied to TimCruise's topic in Tips / Blogs / Tutorials / Videos
Both Matlab and R seem completely inappropriate for this usage scenario. But R is not graphical software. It's best thought of as a scripting language designed for statistical use.- 39 replies
-
- programming hardware
- rad studio
-
(and 1 more)
Tagged with:
-
Reading a binary file hangup without error
David Heffernan replied to William23668's topic in RTL and Delphi Object Pascal
You aren't going to be able to display the contents of a binary file in a rich edit control like this. If you want a hex editor, then display each byte as hex. -
How to get ThisFormClass (TForm1) from Form1
David Heffernan replied to Qasim Shahzad's topic in Algorithms, Data Structures and Class Design
It will work fine so long as you use the virtual constructor and all your classes override that correctly. If you passed in an anon method that creates and returns a newly minted form, that would allow other constructors to be used. To me this is pointless though. It's a really common pattern, it's only a handful of lines. I don't really see the benefit. I mean, if you were trying to centralise some logging or other aspect, then it would make sense. Otherwise I don't really see the benefit. Also the name sucks. Should include the fact that the form is shown modally.- 20 replies
-
- form creation
- refactoring
-
(and 3 more)
Tagged with:
-
How to set TBytes array to the file size ?
David Heffernan replied to William23668's topic in RTL and Delphi Object Pascal
Well you have all of the information you need in a byte array. The index into the array is the address, and the byte value at that index is your value. Job done. -
How to set TBytes array to the file size ?
David Heffernan replied to William23668's topic in RTL and Delphi Object Pascal
You already read every byte!! The real problem here is that you can't explain what you are trying to do. What do you mean about getting every address? An exe file isn't a list of addresses. -
How to set TBytes array to the file size ?
David Heffernan replied to William23668's topic in RTL and Delphi Object Pascal
Then why do you try to convert to a string as if it were UTF16? You seem very confused. Well, yeah, it probably isn't UTF16 is it? It looks like you tried 10 things at random and left them all in the code you posted. -
How to set TBytes array to the file size ?
David Heffernan replied to William23668's topic in RTL and Delphi Object Pascal
The size of the file is AFile.Size. You read the entire file into a byte array, but then go at the same stream with a binary reader. There are so many mistakes here. Do you want to read it into a byte array and covert to string. Or do you want to read it as binary.