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.
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>:
- %s -> take the extracted raw text as is
- %s, -> take the extracted raw text and append a comma
- Add(%s); -> enclose the extracted text with “Add(‘” and “‘);”
- %s + sLineBreak + -> append “+ sLineBreak +” to the text
- %s + #10 + -> append “+ #10 +” to the text
- %s + #13 + -> append “+ #13 +” to the text
- %s + #13#10 + -> append “+ #13#10 +” to the text
- %s + CRLF + -> append “+ CRLF +” to the text
- %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.