Skip to content

Macro Tip: Don’t Be Afraid to Make Mistakes

Joe White is blogging about Delphi IDE macros, so I’ll throw in a useful tip: When recording a macro, it’s OK to make a mistake. Just type Ctrl+Z (Undo) or hit Backspace and retype what you were doing; the correction becomes part of the macro, and it’s a lot easier than re-recording the macro from the start.

I use macros pretty heavily. They’re handy for just about any bulk editing task. For example, I often use them when I write SQL in InterBase PLANalyzer, and then need to paste the SQL into source code. I paste in the entire query, and then use macros to handle the quoting and string concatenation needed to turn the query statement into a valid source code, spanning several lines in the editor.

{ 4 } Comments

  1. Jack Rodenhi | March 31, 2008 at 2:15 pm | Permalink

    I will have to check this out. I do most of my SQL in IBExpert. I copy it into Ultra-Edit with Alt-V which is a hot key that does the necessary reformatting, then selects all of the text and copies it to the clipboard. From there I can switch to Delphi and paste it in. Is it possible to share your macro like I can with Ultra-Edit?

    Do you have a tip for going the other way? The Delphi IDE does not have a memo control for transferring multi-line text. I have been sending to TraceTool, but I still get the line numbers there which necessitates a trip though Ultra-Edit where I can get rid of them using column editing.

  2. Craig Stuntz | April 3, 2008 at 2:29 pm | Permalink

    Jack,

    I don’t know any way to share a Delphi macro other than to describe how to make it. Is that what you would like to see?

    For going the other way (from the Delphi editor to a query tool), I generally use rectangular select (hold down the Alt key while dragging the mouse to select).

  3. Jack Rodenhi | April 3, 2008 at 3:52 pm | Permalink

    Craig,
    Thanks for responding. I am sure I can go through the steps to record a macro. If I run into something, I will be sure to come back. The problem, of course, with the rectangular selection is that it will contain unevaluated variables.

    I love Delphi but I have always thought it was a shame that no one ever put a multi-line variable viewer in it. The Evaluate dialog would be a perfect place. Maybe include a check box for multi-line so you could get something like
    SELECT *
    FROM EMPLOYEE
    that you could paste directly into your query tool
    rather than
    SELECT *#$D#$AFROM EMPLOYEE
    which has to be reformatted.

    The guys at CodeGear don’t miss many opportunities to make life easier on programmers but they missed this one.

    -Jack

  4. Craig Stuntz | April 3, 2008 at 4:07 pm | Permalink

    Jack,

    What I do for Evaluate is to put in something like this:

    {$IFOPT D+}MyQuery.SQL.SaveToFile(Filename);{$ENDIF}

    … to dump SQL to a file in debugging.

    I’ll post the macro separately.

{ 1 } Trackback

  1. […] I use Delphi macros for converting SQL created in a query analysis tool into Delphi constants, and commenter Jack asked for more details on this. I thought it would make a better post than […]

Post a Comment

Your email is never published nor shared. Required fields are marked *
Close