Convert Strings Editor Expert

 

The new Convert Strings editor expert is my first try to replace the existing Paste Strings As, Copy Raw Strings and Convert Raw Strings experts with something that’s easy to use without actually having to memorise how they work. It can probably still be improved.

gexperts_convert-strings

When called, it will automatically check whether there is a selection in the editor, if yes, it takes this, if not, it takes the text from the clipboard, and displays it in the memo on left hand side.

The memo on right hand side shows the text after the changes specified in the middle have been applied.

The two most likely use cases are converting an SQL string from raw text to Delphi source code and back. So I added buttons for setting all options for just that:

  • -> SQL
  • -> TStrings

The first option, which you probably always want to enable is “Extract Raw Strings”, it will remove everything it deems to be Delphi code, be it simple quotes or something like “bla.sql.add(‘…’);”.

Then there is the Convert Type, each can be selected with Alt + <number>:

  1. %s -> take the extracted raw text as is
  2. %s, -> take the extracted raw text and append a comma
  3. Add(%s); -> enclose the extracted text with “Add(‘” and “‘);”
  4. %s + sLineBreak + -> append “+ sLineBreak +” to the text
  5. %s + #10 + -> append “+ #10 +” to the text
  6. %s + #13 + -> append “+ #13 +” to the text
  7. %s + #13#10 + -> append “+ #13#10 +” to the text
  8. %s + CRLF + -> append “+ CRLF +” to the text
  9. %s + CR_LF + -> append “+ CR_LF +” to the text

There two more options:

  • Quote Strings -> enclose the strings in single quotes
  • Append Space -> append a space character to the strings

And then you can add a prefix to each line. This is meant to prefix them with something like “Query1.Sql.”.

There are some buttons on the bottom that should be self explanatory. They copy the current clipboard content to the Input memo, copy the current output memo to the clipboard or to the editor window and close the dialog, or simply close the dialog.

%d bloggers like this: