I have a lot of constants that are somehow related, at some point I need to pair them, something like this:
const
key1 = '1';
key2 = '2';
key3 = '3';
value1 = 'a';
value2 = 'b';
value3 = 'c';
I want to avoid doing:
if MyValue = key1 then Result := value1;
I know how to do it with string lists using:
MyStringList.Add(k...
How does one setup DUnit Testing in a Midas/DataSnap project in Delphi 2006
Edit
How does one set up a Dunit Test into a TRemoteDataModule
The project wizard in Delphi 2006 does not work with TRemoteDataModule
...
I work on a large project in Delphi 5.
Today, after merging two branches of the app together, one of the hundreds of units, UnitMain (the main form's unit, would you guess) stopped recognizing the Application global.
This is a rather bizarre problem - I could get the program to compile by defining Application: TApplication in UnitMain, ...
I have a simple application, which should send a single byte to a serial port once a minute. But sometimes, from some strange reason, it freezes somewhere in the WriteFile() function. Both sw and hw flow controls are turned off. I've googled some stuff about pending read operations performed from another threads, but I believe this is no...
Delphi (and probably a lot of other languages) has class helpers. These provide a way to add extra methods to an existing class. Without making a subclass.
So, what are good uses for class helpers?
...
I’m using SSIS to synchronize data between two databases. I’ve used SSIS and DTS in the past, but I generally write an application for things of this nature (I’m coder and it just comes easier to me).
In my package I use a SQL Task that returns about 15,000 rows. I’ve hooked that up to a Foreach Container, and within that I assign the r...
I want to create a string that spans multiple lines to assign to a Label Caption property. How is this done in Delphi?
...
Some of my MS SQL stored procedures produce messages using the 'print' command. In my Delphi 2007 application, which connects to MS SQL using TADOConnection, how can I view the output of those 'print' commands?
Key requirements:
1) I can't run the query more than once; it might be updating things.
2) I need to see the 'print' results e...
One of Delphi 2009's advertised features was PNG support. That's great, because the Unicode issues break the pngimage.pas library I was using before. Only problem is, I can't find the Delphi 2009 version. Anyone know what it's called, and how difficult it is to migrate existing pngimage.pas-based code to the new library?
...
If I have a type defined as a set of an enumerated type, it's easy to create an empty set with [], but how do I create a full set?
EDIT: Yeah, the obvious solution is to use a for loop. That's also a really bad solution if there's another way. Does anyone know of a way that'll work in constant time?
...
I have a threading problem with Delphi. I guess this is common in other languages too. I have a long process which I do in a thread, that fills a list in main window. But if some parameters change in the mean time, then I should stop current executing thread and start from the beginning. Delphi suggests terminating a thread by setting Te...
Delphi 2009, among some cool stuff, has also just got Anonymous methods. I've seen the examples, and the blog posts regarding anonymous methods, but I don't get them yet. Can someone explain why I should be excited?
...
I'm using an in-memory dataset to represent an array of objects. I've got most of the code figured out to fill the dataset at runtime, but part of my object contains a dynamic array of TPoint records, and I have no idea how to set up the dataset and the loading code to make that work. I know a TPoint can be represented by an ADT field,...
I'm using TNMHTTP in Delphi to retrieve the code from a webpage. The code is relatively simple:
NMHTTP1 := TNMHTTP.Create(Self);
NMHTTP1.InputFileMode := FALSE;
NMHTTP1.OutputFileMode := FALSE;
NMHTTP1.ReportLevel := Status_Basic;
NMHTTP1.TimeOut := 3000;
URL := 'http://www....';
NMHTTP1.Get(URL);
S := NMHTTP1.Body;
I am catching ex...
I have an application that creates, and destroys thousands of objects. Is it worth caching and reusing objects, or is Delphi's memory manager fast enough that creating and destroying objects multiple times is not that great an overhead (as opposed to keeping track of a cache) When I say worth it, of course I'm looking for a performance b...
I'm building a project that uses the JVCL plugin system, which relies on Delphi packages, and ever since I added it to my project, debugging has become a nightmare because I'm no longer able to step-trace into the source of any VCL or RTL units. They're all marked as gray dots in the debugger, (when the relevant functions appear at all ...
I'm getting the memory leak message upon shutdown, saying that I'm leaking 3 of a certain object. Two problems with that, though.
It only happens intermittently. I can run my program, go through the exact same series of steps, (open a data file, display it, and shut down again,) and sometimes the message will show up and sometimes it...
Help !!!
I have just spent about 10 minutes looking for a way to do a search and replace over all the files in Delphi 2006 project.
Please can you tell how to do it
...
I'd like to display a stack trace in an error dialog in Delphi 2007 (Win32).
Ideally, I'd like something like this:
try
//do something
except on e : exception do
begin
//rollback a transaction or whatever i need to do here
MessageDlg('An error has occurred!' + #13#10 +
e.Message + #13#10 +
...
I was looking into using some .NET code from within a Delphi program, I will need to make my program extensible using .net assemblies and predefined functions (I already support regular DLLs).
After a lot of searching online, I found Managed-VCL, but I'm not ready to pay $250 for what I need, I also found some newsgroups with code that...