Delphi pitfalls: Enumerated types and for loops

Not all for loops are created equal.

Consider
for x in [value1, value2, value3]

You would expect to see x vary in the order of the values in the list.

However – if x and the values are of an enumerated type, looping the “list”
does NOT loop in the apparent order of the constant, but in the order of the enumerated type declaration, such as it would for any set.

Continue reading “Delphi pitfalls: Enumerated types and for loops”

Delphi: Pitfalls of Anonymous methods and Capture

I was writing a web request handler when I ran into a problem. I was plugging in multiple handlers, but only one of them actually worked.

Why?

To get to the essence of it, this doesn’t work

procedure TMyClass.Setup;
var
  Handler: THandlerClass;
  hType: THandlers;
begin
  Broker.Clear;
  for hType in [foo, bar]
  do begin
    case hType of
      foo: Handler := TFoo.Create;
      bar: Handler := TBar.Create;
    end;
    Broker.AddHandler(Handler.OnHandle);
  end;
end;

Zipped example source code: https://drive.google.com/open?id=1RxOxOlYOrjqPryW7vGNw40VTLav6IN_M

Continue reading “Delphi: Pitfalls of Anonymous methods and Capture”

Delphi Developers Archive (Experimental)

Delphi Developers Archive (Experimental)

 

https://delphi-developers-archive.blogspot.com

 

The posts are searchable by tag list or free text search.

 

FYI – This is work in progress, and I hope to improve the following issues:

– Some posts have erroneous titles

– Some posts are missing attribution of the original poster

– Some 600 posts are missing due to an inexplicable quota error during import

 

Comments on the archived posts are currently disabled until the import is finalized.

We are looking for an experienced Delphi developer for a permanent position in our Industrial IT team at TINE SA,…

We are looking for an experienced Delphi developer for a permanent position in our Industrial IT team at TINE SA, Norway’s largest dairy product company.

About TINE: https://www.tine.no/english

Language and Location requirements

You must be able to speak/read/write Norwegian and English fluently, and be able to work at TINE’s offices at Kalbakken in Oslo.

Coding skills you need

– Modern Delphi OOP code with generics and attributes

– Delphi VCL / Windows APIs / FireDAC

– MS SQL Server T-SQL and SQL queries in general

– Basic http/tcp/udp networking

– XML/JSON knowledge

Coding skills that would be nice

– Delphi FireMonkey on iOS/Android

– MSVS C#/.NET

– MS PowerShell

– HTML5/JS/CSS

Bonus skills that come in handy

– Datawarehousing and big data

– IoT (the buzz, the hype, the stuff that works)

– Knowledge of the various aspects of Logistics and exchanging information between actors (GS1)

– Jira/SVN/git experience

Person skills we really appreciate

– Open and honest and not afraid to speak your mind

– Able to communicate clearly in writing

– Works well with others and can take and give positive feedback

– Willing to learn and adapt, as well as share and mentor

– Able to focus on and prioritize tasks, putting need before cool/fun

You have been programming for a while and can document your experience.

Please send your questions to

lars.fosdal (at) http://tine.no

Please note: Official posting will come later.

I wrote a function to make JSON more readable, and naturally I wonder if I missed something crucial so that it…

I wrote a function to make JSON more readable, and naturally I wonder if I missed something crucial so that it eventually will break?

There are probably more efficient ways to work with strings than concatenating character by character, but performance was not a key goal.

I hereby commit it to public code review 😉

https://pastebin.com/Juks92Y2