Codehunter 0 Posted November 11, 2020 Hello! Would be nice to have an type "%s +" in the PasteAs options for SQL statements. There is not neccessary to include any linebreak in the string itself, only in the Pascal source. LSQL := 'SELECT * ' + 'FROM myTable ' + 'WHERE myCol=1 ' + 'ORDER BY id DESC'; Please note the space prior to the closing quotemark in each line. Greetz Cody Share this post Link to post
Lars Fosdal 1792 Posted November 11, 2020 I totally agree, and it has been suggested for years. No joy so far. Unneeded whitespace and linebreaks should be eliminated. LSQL := "SELECT * FROM myTable WHERE myCol=1 ORDER BY id DESC"; 2 Share this post Link to post
Arnaud Bouchez 407 Posted November 11, 2020 Some tools - like cnpack IIRC - allow to format the text into source code string after being pasted. Share this post Link to post
Attila Kovacs 629 Posted November 11, 2020 (edited) That is so easy, a little wizard with 2 menus. Forgive me for the code quality, looks like I did not give too much flamingos about it. // Paste procedure TClipboardWizard.mePasteFromClipboard(Sender: TObject); begin with BorlandIDEServices as IOTAEditorServices do if Assigned(TopView) then begin TopView.Buffer.EditPosition.InsertText(GetFormattedString); TopView.Paint; // invalidation end; end; function TClipboardWizard.GetFormattedString: string; var List: TStringList; q: integer; begin if Clipboard.HasFormat(CF_TEXT) then begin List := TStringList.Create; try List.Text := Clipboard.AsText; for q := 0 to List.Count - 2 do List[q] := #39 + List[q].Trim.Replace(#39, #39#39) + #32#39#43#32#47#47; q := List.Count - 1; List[q] := #39 + List[q].Trim.Replace(#39, #39#39) + #32#39#59#32#47#47; Result := List.Text; finally List.Free; end; end; end; //Copy procedure TClipboardWizard.meCopyToClipboard(Sender: TObject); begin with BorlandIDEServices as IOTAEditorServices do if Assigned(TopView) then Clipboard.AsText := RemoveUnneededChars(TopView.Block.Text); end; function TClipboardWizard.RemoveUnneededChars(const Value: string): string; var List: TStringList; q: integer; begin if Value.Trim <> '' then begin List := TStringList.Create; try List.Text := Value; for q := 0 to List.Count - 1 do List[q] := List[q].Trim([#32, #33, #34, #35, #36, #37, #38, #40, #41, #42, #43, #44, #45, #46, #47, #48, #49, #50, #51, #52, #53, #54, #55, #56, #57, #58, #59, #60, #61, #62, #63, #64, #65, #66, #67, #68, #69, #70, #71, #72, #73, #74, #75, #76, #77, #78, #79, #80, #81, #82, #83, #84, #85, #86, #87, #88, #89, #90, #91, #92, #93, #94, #95, #96, #97, #98, #99, #100, #101, #102, #103, #104, #105, #106, #107, #108, #109, #110, #111, #112, #113, #114, #115, #116, #117, #118, #119, #120, #121, #122, #123, #124, #125, #126, #127]).Replace(#39#39#39, #39#39#32#39).Trim([#39]).Replace(#39#39, #39); Result := List.Text; finally List.Free; end; end else Result := ''; end; Edited November 11, 2020 by Attila Kovacs Share this post Link to post
Codehunter 0 Posted November 11, 2020 6 minutes ago, Lars Fosdal said: I totally agree, and it has been suggested for years. No joy so far. Unneeded whitespace and linebreaks should be eliminated. LSQL := "SELECT * FROM myTable WHERE myCol=1 ORDER BY id DESC"; But your snippet seems to be like pseudocode, its not Delphi/Pascal 🙂 I'm used such constructs in PHP and let the DBMS strip all unneeded stuff. But Delphi/Pascal doesnt support multiline strings like in your snippet. The resulting SQL Statement should be: SELECT * FROM myTable WHERE myCol=1 ORDER BY id DESC 10 minutes ago, Arnaud Bouchez said: Some tools - like cnpack IIRC - allow to format the text into source code string after being pasted. Oh yeah, lets remove all the stuff from GExperts which exists in other Tools 😉 The Apple Way: Nothing can exist in our Appstore that is already offered by us. 🤬 IMHO the best way is a competition between the best ideas. I know that other IDE experts have similar or better implementations but why not improve GExperts? Sometimes the others are unstable or unusable in some situations. Esp. CnPack is very tricky in the Editor Experts, therefore I have completely disabled this part. Share this post Link to post
Lars Fosdal 1792 Posted November 11, 2020 It is pseudocode - the way we'd want it to work - and as I said, there has been QP or QC's created for this before. 1 Share this post Link to post
Attila Kovacs 629 Posted November 11, 2020 @Lars Fosdal It's the GExperts section 😛 Again 😉 Maybe we need some css tuning on the title 😉 Share this post Link to post
Lars Fosdal 1792 Posted November 11, 2020 I just need better reading comprehension, @Attila Kovacs. My bad. Share this post Link to post
Codehunter 0 Posted November 11, 2020 12 minutes ago, Lars Fosdal said: It is pseudocode - the way we'd want it to work - and as I said, there has been QP or QC's created for this before. This was not meant as critic 🙂 As you can see at the left, I'm not so often here... Mostly in the german DP Share this post Link to post
dummzeuch 1505 Posted November 11, 2020 4 hours ago, Lars Fosdal said: I totally agree, and it has been suggested for years. No joy so far. Where? Share this post Link to post
Attila Kovacs 629 Posted November 11, 2020 A blind man walks into a bar. And a table. And a door. And a staircase. Share this post Link to post
dummzeuch 1505 Posted November 11, 2020 1 hour ago, dummzeuch said: Where? Ah, this was about Delphi, not GExperts. Share this post Link to post
Edwin Yip 154 Posted November 12, 2020 17 hours ago, Lars Fosdal said: I totally agree, and it has been suggested for years. No joy so far. Unneeded whitespace and linebreaks should be eliminated. LSQL := "SELECT * FROM myTable WHERE myCol=1 ORDER BY id DESC"; This is the only one language feature I want to be added to Delphi if I can choose only one. I think it's called multi-line string literals? I think use we should keep using the single quotes, because sometimes we have double quotes in the string when working with html or SQL. Share this post Link to post
dummzeuch 1505 Posted November 14, 2020 (edited) On 11/11/2020 at 11:22 AM, Codehunter said: Would be nice to have an type "%s +" in the PasteAs options for SQL statements. There is not neccessary to include any linebreak in the string itself, only in the Pascal source. LSQL := 'SELECT * ' + 'FROM myTable ' + 'WHERE myCol=1 ' + 'ORDER BY id DESC'; Have you looked at the newer "Convert Strings" expert? There is a favorite called "SQL-to-String" which seems to do exactly what you want Edited November 14, 2020 by dummzeuch Share this post Link to post
Codehunter 0 Posted November 17, 2020 On 11/14/2020 at 1:51 PM, dummzeuch said: Have you looked at the newer "Convert Strings" expert? There is a favorite called "SQL-to-String" which seems to do exactly what you want Thanks! This is exactly what I want. But a little confusing. Maybe the Convert Strings expert can supercede the String Paste as expert because the last is a subset of the first. Share this post Link to post
dummzeuch 1505 Posted November 17, 2020 2 hours ago, Codehunter said: Thanks! This is exactly what I want. But a little confusing. Maybe the Convert Strings expert can supercede the String Paste as expert because the last is a subset of the first. I wrote the Convert Strings expert several months after somebody else donated the String Paste expert, because I could never remember how to use the latter. I always wanted to clean up this mess, but never came around doing it. Share this post Link to post