TwoDesk Delphi Blog

TwoDesk Delphi Blog

Hi, I'm Jacob. I'm a computer programmer and the owner of TwoDesk Software Company.

In this blog, I write about the Delphi programming language and provide tips, tricks, and training for Castalia, a tool that I've written for other programmers using the Delphi programming language.

07 July 2011 ~ 0 Comments

Speaking of Delphi 7…

Speaking of Delphi 7, I just learned that if you buy Delphi XE, you get earlier versions 7, 2007, 2009, and 2010 at no extra cost. There’s more information at www.embarcadero.com/products/delphi/previous-versions.

One thing that’s really interesting to me is that Delphi 7 is part of this package (and, in fact, is still available for sale separately), but Delphi 8, 2005, and 2006 are not, even though they came after Delphi 7. 

Did you know that Castalia works every version of Delphi from 5 to XE, including Delphi 7? (Except for Delphi 8, because there is literally nobody using it). See how Castalia can make your awesome Delphi IDE even better at www.twodesk.com/castalia.

06 July 2011 ~ 3 Comments

Delphi 7 is still popular

I recently ran a survey of a sample of Castalia users. One of the questions I asked was “Which version(s) of Delphi are you currently using?”

Of those who responded to the survey, 50% said they are using Delphi XE, and 50% said they are still using Delphi 7.

Two things to keep in mind:

1. This was a multiple-answer survey question, so the fact that those add up to 100% means nothing. Many people are using multiple versions of Delphi for multiple projects.

2. I would like to think that Castalia users represent a cross-section of Delphi users, and that these numbers are representative of the Delphi user population as a whole, but I don’t know that for certain.

In any case, it’s interesting that Delphi 7 is still high in the popularity rankings, despite being so old.

Did you know that Castalia works every version of Delphi from 5 to XE, including Delphi 7? (Except for Delphi 8, because there is literally nobody using it). See how Castalia can make your awesome Delphi IDE even better at www.twodesk.com/castalia.

05 July 2011 ~ 0 Comments

Castalia’s Inline Variable Declaration

One of the biggest complaints I hear about Delphi syntax is the need to declare variables at the top of a function before they can be used. Other languages, like C++ or java, let you declare a variable at any point in your code. I have mixed feelings about this.

On the one hand, I believe that Delphi’s approach (require all variables to be declared in a VAR section at the beginning of a function) is stronger and more readable, and that it gives you a quick at-a-glance feeling for the data being used in your function. It also contributes to Delphi’s lightning-fast compile times, for reasons that are beyond the scope of this post.

On the other hand, it can be an annoyance to have to jump back into the VAR section of the Delphi function every time you need another variable. It breaks up your mental “flow” and, in particularly large and complex functions, can cost time and effort in getting back to where you left off.

This is the reason I created Inline Variable Declaration in Castalia for Delphi.

Inline Variable Declaration gives you the best of both worlds. It lets you write a VAR declaration anywhere in your function, and then automatically moves that VAR declaration into the variable declaration section of your function without breaking your flow or losing your place.

Inline Variable Declaration isn’t a very discoverable feature the Castalia adds to Delphi – you have to know it’s there, but once you do, it can save you a little time and a lot of mental effort.

For more information on Inline Variable Declaration in Castalia for Delphi, see http://twodesk.com/castalia/codingassistance.html#inlinevars

20 June 2011 ~ 1 Comment

Castalia Code Templates – A Primer

Castalia’s code template system for the Delphi IDE is actually a scripting system. Borrowing from web programming systems like PHP or ASP, Castalia’s templates are a combination of text to be inserted directly into the editor and of scripting code, contained between {% and %} markers.

The scripting language is Delphi-based, so there’s no syntax to learn as you write really powerful code templates. Here’s an example of what the ifb template looks like (ifb inserts an if statement with a begin..end block):

    if {% InsertCursor(0) %} then
    begin
    {%= Indent %}{% InsertCursor (1) %}
    end;

Everything not between {% %} markers is inserted directly into the Delphi code editor. Code between the {% %} markers is executed. This example shows the InsertCursor(AOrder: Integer) procedure, which drops a stack bookmark at that point in the text. The bookmark with AOrder = 0 will be the location of the cursor after the template is done executing. The bookmarks are then picked up in the order indicated by the AOrder parameter.

Also notice the {%= marker, which means “insert the result of this code into the editor.” Indent returns a string of spaces matching your indent size.

Here’s an example of a template to insert the current method name as a string:

    {% if ClassName <> ” then
    begin
    %}{%= ClassName %}.{% end %}{%= ProcedureName %}

Notice the Delphi code right in the template to check whether there is a current class and insert the “ClassName.” before the method name.

Castalia comes with quite a few built-in templates, but the real power is in writing your own.

Castalia Delphi code template editor

Want to give it a try? Download Castalia today and see what you can do with Castalia’s powerful code templates for the Delphi IDE.

17 June 2011 ~ 0 Comments

Welcome

Welcome to the new Castalia blog. Previously, my blog at www.jacobthurman.com was a big unfocused collection of not-necessarily-related things.

Now, instead having to comb through that blog in order to find information on Castalia, you can find it all here.

Don’t forget to sign up for my free newsletter and get exclusive content for free, plus a chance to win a programming book every month.