Jump to content

Recommended Posts

I wish everyone a healthy day.

MyStr :='Lorem Ipsum   ';

I want to delete ALL empty/blank strings end of MyStr

( I dont know MyStr has how many empty strings )

Required Result :='Lorem Ipsum'

Thank You

Share this post


Link to post
Posted (edited)

ofc, the naming of TrimRight is a bit of a slap in the face for Arabic speakers and other RTL languages!!! 

 

Should really be TrimEnd and TrimBeginning or something like that... 

Edited by David Heffernan
  • Like 1

Share this post


Link to post
1 minute ago, David Heffernan said:

ofc, the naming of TrimRight is a bit of a slap in the face for Arabic speakers and other RTL languages!!! 

 

Should really be TrimEnd and TrimBeginning or something like that... 

Android API moved from such ambiguous methods and properties named left/right to start/end so following that rule it would be TrimEnd and TrimStart 

Share this post


Link to post
3 hours ago, Dalija Prasnikar said:

TrimEnd and TrimStart 

I think start should pair with finish, begin pairs with end, from pairs with to, etc. Don't really like start paired with end. 

  • Like 1

Share this post


Link to post

FMX uses terms  leading trailing ...

Just saying.

  • Like 1

Share this post


Link to post
5 hours ago, David Heffernan said:

I think start should pair with finish, begin pairs with end, from pairs with to, etc. Don't really like start paired with end. 

Interesting...  as non native English speaker, I guess I don't immediately see the difference. Above pairing generally makes sense.

 

In this case, from my perspective TrimBeginning is extremely awkward to write.

Share this post


Link to post
24 minutes ago, Dalija Prasnikar said:

Sounds better.

Yeah, this is much better. And a good matching pair too. 

Share this post


Link to post
25 minutes ago, Dalija Prasnikar said:

Interesting...  as non native English speaker, I guess I don't immediately see the difference. Above pairing generally makes sense.

 

In this case, from my perspective TrimBeginning is extremely awkward to write.

Start goes with finish, begin goes with end for nouns at least. For verbs start and stop are pairs. 

  • Thanks 1

Share this post


Link to post
5 hours ago, Dalija Prasnikar said:

as non native English speaker

By the way -I bought your new book, and found it very well written.  The writing style is probably the best (or one of the best) of all the Delphi technical writers whose book I've read.  Last time I found such a good technical writer was Delphi in a Nutshell by Ray Lischner .  I look forward to more of your books - or maybe you might want to update the Memory Management book considering now Delphi has a uniform memory manager?

  • Thanks 1

Share this post


Link to post
7 hours ago, wuwuxin said:

By the way -I bought your new book, and found it very well written.  The writing style is probably the best (or one of the best) of all the Delphi technical writers whose book I've read.  Last time I found such a good technical writer was Delphi in a Nutshell by Ray Lischner .  I look forward to more of your books -

Thanks! That means a lot 🙂

7 hours ago, wuwuxin said:

or maybe you might want to update the Memory Management book considering now Delphi has a uniform memory manager?

Since books covers both classic and ARC compilers, unifying memory management does not have huge impact on the book content. Only DisposeOf chapter and few references to mobile (previously ARC) compiler when it comes to reference counting for object references no longer apply. 

 

New mobile compilers now behave exactly like classic compiler, and memory management for that one hasn't changed. 

 

Eventually, there will be some book update, but not for now. There is not much going on in the memory management area that would warrant updating the book. 

Share this post


Link to post
14 hours ago, Dalija Prasnikar said:

In this case, from my perspective TrimBeginning is extremely awkward to write.

Nothing will beat IncludeTrailingPathDelimiter

Share this post


Link to post
15 minutes ago, Fr0sT.Brutal said:

Nothing will beat IncludeTrailingPathDelimiter

🙂 Fortunately it is usually enough to type "incl", press Ctrl+space, arrow down, enter.

Share this post


Link to post
2 hours ago, Fr0sT.Brutal said:

Nothing will beat IncludeTrailingPathDelimiter

Dont get your point, there is AutoCompletion :classic_biggrin:

 

I think thats much better to have speaking names than some like AK, DoIt, Run, InTrlPaDel, aThng, ....

(I don't care much about the grammar).

 

And since LSP, we can "AutoComplete" within terms too, above you can find by "Inc", "Trail", "Path", "Del"

Share this post


Link to post
1 hour ago, Rollo62 said:

And since LSP, we can "AutoComplete" within terms too, above you can find by "Inc", "Trail", "Path", "Del"

LSP has nothing to do with that but the filter in the suggestion box. There were several plugins that could do that for ages.

Share this post


Link to post
11 minutes ago, Stefan Glienke said:

LSP has nothing to do with that but the filter in the suggestion box. There were several plugins that could do that for ages.

Maybe so, but since LSP I recognize that this behaviour has changed to older versions.

Before it was able to filter only from beginning of terms, now it filters everywhere.

Anyway for what reason: Hooray its getting more usable :classic_cheerleader:

Share this post


Link to post
Posted (edited)

OTOH, some old-school C functions are another edge of insanity. itoa? strstr?? And the absolute winner - printf, fprintf, sprintf, snprintf, printf_s, fprintf_s, sprintf_s, snprintf_s, _sprintf_l, swprintf, _swprintf_l, __swprintf_l, sprintf_s, _sprintf_s_l, swprintf_s, _swprintf_s_l, _sprintf_p, _sprintf_p_l, _swprintf_p, _swprintf_p_l, vsprintf, _vsprintf_l, vswprintf, _vswprintf_l, __vswprintf_l, vsprintf_s, _vsprintf_s_l, vswprintf_s, _vswprintf_s_l, _vsprintf_p, _vsprintf_p_l, _vswprintf_p, _vswprintf_p_l, vsnprintf, _vsnprintf, _vsnprintf_l, _vsnwprintf, _vsnwprintf_l, vsnprintf_s, _vsnprintf_s, _vsnprintf_s_l, _vsnwprintf_s, _vsnwprintf_s_l, WTFPRINTF!!!

Edited by Fr0sT.Brutal
  • Haha 2

Share this post


Link to post

Wasn't there also a series of aprintf which allocates the memory before doing the printf stuff? ;)

Share this post


Link to post
Posted (edited)
14 minutes ago, luebbe said:

Wasn't there also a series of aprintf which allocates the memory before doing the printf stuff? 😉

IDK and I don't dare to go further into that cave of madness %-) there be monsters!

Edited by Fr0sT.Brutal

Share this post


Link to post

Back to the original topic

On 4/25/2021 at 10:33 AM, David Heffernan said:

ofc, the naming of TrimRight is a bit of a slap in the face for Arabic speakers and other RTL languages!!! 

 

Should really be TrimEnd and TrimBeginning or something like that... 

Funnily enough TrimStart and TrimEnd helper methods exist in TStringHelper, but were deprecated in favor of TrimLeft and TrimRight:

TStringHelper = record helper for string
  { ... }
  function TrimEnd(const TrimChars: array of Char): string; deprecated 'Use TrimRight';
  function TrimStart(const TrimChars: array of Char): string; deprecated 'Use TrimLeft';
  { ... }
end;

 

Share this post


Link to post
On 4/25/2021 at 3:42 AM, Henry Olive said:

I wish everyone a healthy day.

MyStr :='Lorem Ipsum   ';

I want to delete ALL empty/blank strings end of MyStr

( I dont know MyStr has how many empty strings )

Required Result :='Lorem Ipsum'

Thank You

Apart from TrimRight, there is also TrimLeft (trim spaces from left side) and Trim (trim spaces from both sides):
 

TrimLeft('  LoremIpsum') -> 'LoremIpsum'
Trim('  LoremIpsum  ')   -> 'LoremIpsum'

Just try to avoid using TrimLeft and TrimRight in combination like this:

s := TrimLeft(TrimRight('  LoremIpsum  ')); // or TrimRight(TrimLeft())

this is wasteful and unnecessary complicated. Just use Trim instead.

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×