The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,862 other subscribers

Archive for the ‘Delphi’ Category

Working in a team? DprojSplitter might be helpful! | The Art of Delphi Programming

Posted by jpluimers on 2019/11/12

Reminder to self: split off the user settings from a Delphi .dproj so only the non-user settings get into your version control system.

Some of you are probably already using my DprojNormalizer plugin for Delphi, which tries to reduce the unwanted differences disturbing your version control system. It does this by forcing a dedicat…

So what about them?
DprojSplitter handles the current build configuration and current platform. In addition these settings are handled, too (found in CommonOptionStrs):

sDebugger_RunParams,
sDebugger_RemoteRunParams,
sDebugger_HostApplication,
sDebugger_RemotePath,
sDebugger_RemoteHost,
sDebugger_EnvVars,
sDebugger_SymTabs,
sDebugger_Launcher,
sDebugger_RemoteLauncher,
sDebugger_IncludeSystemVars,
sDebugger_UseLauncher,
sDebugger_UseRemoteLauncher,
sDebugger_CWD,
sDebugger_RemoteCWD,
sDebugger_RemoteDebug,
sDebugger_DebugSourcePath,
sDebugger_LoadAllSymbols,
sDebugger_LoadUnspecifiedSymbols,
sDebugger_SymbolSourcePath

Source: [WayBackWorking in a team? DprojSplitter might be helpful! | The Art of Delphi Programming

via: [WayBack] Oops! I did it again! This is my new IDE plugin – again targeted on dproj files. – Uwe Raabe – Google+

–jeroen

Posted in Delphi, Development, Software Development | Leave a Comment »

How to convert a Delphi enum or set to a JSON value, with different specific values…

Posted by jpluimers on 2019/11/07

As I will probably need this one day: [WayBack] How does one convert a Delphi enum to a JSON value, with different specific values? – CHUA Chee Wee – Google+:

eg, TEnum1 = (test1, test2, test3)

TSomeClass.FEnum := test1;

When converted to JSON, I’d like to see maybe
{"Enum": "Value1"} instead of test1

and test2 to "Godzilla", test3 to "Tiburon"

The solution is in his repository: github/chuacw/EnumJson:

After initially suggesting to look into [Archive.is] Serializing User Objects – RAD Studio, he based his solution on a set of clever tricks circumventing Delphi compiler limitations and bugs:

Later he extended the solution to include sets in additions to enums: [Archive.is] Persisting enumeration and sets to JSON – Chee Wee’s blog: IT solutions for Singapore and companies worldwide (via [Archive.isMade my JSON interceptor demo public. Now you can save your enum and sets to JSON, with customized output to boot! – CHUA Chee Wee – Google+)

Clever!

Hopefully this got Lars Fosdal some ideas to solve [WayBackJSON in Berlin – Can I persuade TJSon to treat “params” as it was a string and not an object for the TJsonRPC class? – Lars Fosdal – Google+

Enums with Delphi

Enums with Delphi and their mapping is a repeating topic, see for instance [WayBack] What’s the easiest (ie., least coding) way to map an enum to a const string and vice versa? (Can attributes be used on enum values yet?) eg., type TMyColor… – David Schwartz – Google+

It shows how much the Delphi language is in need of language enhancements as right now there are way too many open source libraries struggling with the same issues each working around them or providing solutions in slightly different way.

Three things immediately come to mind:

  • the NameOf that – analogous to TypeOf – gets the name of an identifier as a string
  • expose all RTTI for all enum types (especially the ones with non-contiguous values or starting at another value than ordinal zero)
  • allow for attributes on enum values

Some examples of libraries providing enumeration support:

Some more thoughts from a different perspective: [WayBackWhat’s New in Edge Rails: Active Record enums

–jeroen

Read the rest of this entry »

Posted in Conference Topics, Conferences, Delphi, Development, Event, Software Development | Leave a Comment »

Changing the order of TabSheets in a PageControl in Delphi – twm’s blog

Posted by jpluimers on 2019/11/06

Good to know this as the Structure View sometimes lets me down: modify the PageIndex position as it is less stable than the Object Treeview in Delphi 7 and below.

Via:

–jeroen

Posted in Delphi, Development, Software Development | Leave a Comment »

Next up: TPDFPrinter and TPDFCanvas Expect a high paced (and easy) update cy…

Posted by jpluimers on 2019/11/05

For my link archive: [WayBack] Next up: TPDFPrinter and TPDFCanvas Expect a high paced (and easy) update cycle for Ultra, with a constant stream of new goodies! Zero hassles – it … – Joe C. Hecht – Google+

–jeroen

Posted in Delphi, Development, PDF, Power User, Software Development | Leave a Comment »

When whas the global FormatSettings variable deprecated?

Posted by jpluimers on 2019/11/05

Reminder to self to check out when [Archive.isFormatSettings global variable of type [WayBackTFormatSettings was deprecated as it was only documented as of Delphi 2010 but available much much earlier.

–jeroen

via [WayBackdelphi – Is there a consistent global FormatSettings variable availabe? – Stack Overflow

Posted in Delphi, Development, Software Development | 2 Comments »

Before using the PPL, I need to check to see if a few things have been fixed yet

Posted by jpluimers on 2019/10/31

Before using the PPL ever, I need to check out at least a few posts like these:

Most of the PPL code was written by Allen Bauer when he was Chief Scientist at Embarcadero in the 2007-2010 time frame and it was still called DPL (Delphi Parallel Library). The code was released in Delphi XE7 (see [Archive.isUsing the Parallel Programming Library – RAD Studio) but seems hardly maintained after he left.

You can find some of his notes at [Archive.isThe Oracle at Delphi: Parallel Programming

–jeroen

Read the rest of this entry »

Posted in Delphi, Development, Software Development | Leave a Comment »

E2398 Class methods in record types must be static (Delphi) – RAD Studio

Posted by jpluimers on 2019/10/29

[WayBack] E2398 Class methods in record types must be static (Delphi) – RAD Studio present since at least Delphi 2007 ([WayBack] E2398: Class methods in record types must be static).

This is a Delphi compiler limitation for records, that is not present for classes.

Maybe one day when record inheritance kicks in, this will be resolved (as Stefan Glienke hinted in the below tread), because currently Self (which is present in non-static class methods on classes) then points to the current type. In static class methods, there is no Self, which is OK as that would point to the only available type anyway.

Via: [WayBack] why a class method of a record without the static keyword raise E2998 error ? AFAIK it can not be anything else then static ?! – Paul TOTH – Google+

Note that [WayBack] Error and Warning Messages (Delphi) – RAD Studio shows various other errors around the use of static:

All are marked “No further information is available for this error or warning.“, though they would at least deserve some examples.

–jeroen

Posted in Delphi, Development, Software Development | Leave a Comment »

Spring4d Marshmallow ORM – ensuring the right identifier quoting is used

Posted by jpluimers on 2019/10/29

When an ORM generates the SQL for a certain database back-end, it needs to use the right quoting.

Normally, the Spring4D Marshmallow project derives that from the back-end specific adapter used.

But if you use a generic TDriverConnectionAdapter, then you need to manually set the QueryLanguage property in your IDBConnection using a valid value from Spring.Persistence.SQL.Interfaces. This then uses the correct SQLGenerator from the TSQLGeneratorRegister to generate the SQL including correct quotes.

To quote identifiers, most back-ends use a double quote, but MySQL uses a backtick.

via:

You obviously already modified that code as the commented out code is the correct one.
I guess you already got that mistake when you started using MySQL via ADO as MySQL needs the backtick.

Set QueryLanguage of your IDBConnection properly (the valid values are in Spring.Persistence.SQL.Interfaces). Then the correct SQLGenerator will be used.
If you are using an adapter that is specific to a certain database then it sets the QueryLanguage properly but if you are using an adapter for components that can connect to multiple databases (like ADO or FireDAC) it does not, hence the need you specify it.

 

–jeroen

Posted in Delphi, Development, Software Development, Spring4D | Leave a Comment »

Delphi code completion fail with anonymous methods – Stack Overflow

Posted by jpluimers on 2019/10/28

[WayBack] Delphi code completion fail with anonymous methods – Stack Overflow.

It also often fails by inserting end; inside if/then/else statements having a proper begin/end blocks.

The reason is that code completion uses a different parser than the regular Delphi compiler.

Chances of these issues to get fixed are close to zero, because another part of the problem is that there is no formalised Delphi language grammar, not even at Embarcadero itself.

I wish there was an Embarcadero sanctioned grammar (see [WayBack] “The arguments that won the day for us here were about strengthening the ecosystem and becoming the best tooled language on the planet. They were about … – Jeroen Wiert Pluimers – Google+). Actually I had that wish like in the end of the 1990s, but I cannot find my forum post archive back.

The best reverse engineered grammar is DelphiAST: a well maintained open source project implementing an Abstract Syntax Tree for Delphi.

Via: [WayBack] SO…/delphi-code-completion-fail-with-anonymous-methods I have seen this question and I am curious. There is an… – Alberto Miola – Google+

–jeroen

Posted in Delphi, Development, Software Development | Leave a Comment »

use the JVCL’s TJvXxxAppStorage to store float values as strings while controlling the decimal separator…

Posted by jpluimers on 2019/10/24

For my link archive: [WayBack] Is there a way to use the JVCL’s TJvXxxAppStorage to store float values as strings (e.g. “10.152”) rather than hex dumps and also control the decimal separator… – Thomas Mueller (dummzeuch) – Google+ with a solution by Achim Kalwa:

+Thomas Mueller You may try this:

type
  TMyStorage = class(TJvAppRegistryStorage)
  protected
    procedure DoWriteFloat(const Path: string; Value: Extended); override;
  end;
  TJvAppRegistryStorage = class(TMyStorage);
...
Implementation

{ TMyStorage }

procedure TMyStorage.DoWriteFloat(const Path: String; Value: Extended);
var
  SValue : string;
  FS     : TFormatSettings;
begin
  FS := TFormatSettings.Create;
  FS.DecimalSeparator := '.';
  FS.ThousandSeparator := #0;
  SValue := FloatToStr(Value, FS);
  DoWriteString(Path, SValue);
end;

And you need to set
StorageOptions.FloatAsString := False;

–jeroen

 

Posted in Delphi, Development, Software Development | Leave a Comment »