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,380 other followers

Archive for the ‘Delphi XE8’ Category

Delphi, IBX and the Turkish I problem

Posted by jpluimers on 2018/06/13

Last year, it took a while to reproduce and it is likely not fixed anytime soon: if you use Delphi and IBX (InterBase Express) to connect to either InterBase or FireBird database, then in the Turkish locale do not use lowercase SQL in your Delphi code as it will break on the

I’ve decided to put this in a separate post than the one I discovered the issue in as that one focused on the Unicode and language background of the various i/I/ characters and this post on the Delphi part.

So for the non-Delphi part, read Source: Field “id” not found and the The Turkish-İ/I/i/ı and case conversion – Update on the dasBlog Turkish-I bug and a reminder to me on Globalization – Scott Hanselman.

In general, this problem is called [WayBack] Case Folding and many environments do not have good and ready to use solutions for this.

Basically when working with case-insensitive language identifiers, you should always use culture invariant text comparison operations. In most languages, people use either lowercase or uppercase converted operations which for Delphi >= come down to using :

The reason is simple:

  • without any parameter, ToLower and ToUpper will use [Archive.isSysLocale.DefaultLCID.
  • without any parameter, LowerCase and UpperCase will implicitly behave as if called with TLocaleOptions.loInvariantLocale, but lots of people forget they do.

The functions ToLowerInvariant and  ToUpperInvariant  were added in Delphi XE3, but ToLower(LocaleID) and ToUpper(LocaleID) in Delphi XE4.

Instead of doing uppercase and lowercase comparisons you could also use the [Archive.isSystem.SysUtils.CompareText function.

IBX however uses case conversion, and by now you will probably guessed it: IBX got it all wrong. One reproduction is at https://gist.github.com/jpluimers/643b382944ff991d07ec96abbf85548c and a thread with background is at [WayBack] What’s the Delphi equivalent of doing UpperCase with an InvariantCulture in Unicode Delphi versions? (XE and up) – Jeroen Wiert Pluimers – Google+

IBX isn’t alone: just search for other uppercase issues like Turkish i to see tons of other issues.

For IBX, I did the replacements in the diff below to fix it in Delphi XE8. I only replaced where identifiers were compared, not were actual database content was compared.

Unluckily, in the past IBX sources were hosted on CodeCentral at http://cc.embarcadero.com/Author/102 but no new bundles have been released since 2012.

Of all the locations I think IBX should not have used any case conversion here:

IBX.IBDatabaseINI.pasfunction LocalServerPath(sFile: string): string

This function uses LowerCase() but I think an NTFS specific comparison should have been used, but I’ve not investigated into a solution for that yet.

–jeroen

Read the rest of this entry »

Posted in Delphi, Delphi 10 Seattle, Delphi 10.1 Berlin (BigBen), Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Delphi XE8, Development, Software Development | Leave a Comment »

delphi – How to get rid of exception 80000003? – Stack Overflow

Posted by jpluimers on 2018/05/02

The [WayBackdelphi – How to get rid of exception 80000003? – Stack Overflow got me on the right track:

When I run my program (admittedly, it was built in debug mode), I get an error “External exception 80000003”.

According to Win32 Exception/Access Violation Errors it means 0x80000003 EXCEPTION_BREAKPOINT A breakpoint was encountered.

What happened was that during debugging a multi-threaded application doing quite a bit of Windows API stuff and CPU debugger Windows stuff by single-stepping through it.

Single-stepping involves the debugger putting a lot of temporary breakpoints similar to how other debuggers do this:

when stepping at the source level, the debugger uses temporary breakpoints to stop execution at the specified location

Source: [WayBackARM Information Center – ARM DS-5 Using the Debugger – Stepping through an application

On Intel platforms, temporary breakpoints are usually done using an INT 3 instruction as that encodes in the single-byte 0xCC opcode. which is very simple for the debugger to patch and remove: just keep a list of addresses and the original byte content.

Note that some debuggers even allow you to manually set temporary breakpoints that disappear after 1-time use; see [WayBackTemporary Breakpoint – Now You See It, Now You Don’t – mohit.io:

Have you faced the problem of breakpoint clutter where breakpoints keep piling up only to hinder the debugging session?  It is then that one realizes that there are some breakpoints that can be deleted and others disabled. A useful feature in a debugger is a temporary breakpoint that automagically gets deleted when hit thereby reducing the clutter of unnecessary breakpoints.

Somehow this doesn’t work well all the time in the Delphi debugger when using multi-threading, but not in a reproducible way: you get a 0x80000003 exception at irregular moments, but more often when you use more threads.

The solution:

  • do not single step
  • configure the IDE to save the desktop (as that contains your breakpoint settings)
  • put regular breakpoints but configure them to be
    • non-breaking
    • log expressions you are interested in
    • put them in a breakpoint group organised by areas you are interested in
    • turn off/on breakpoint groups when certain breakpoints are hit

The above is far more painstaking than using single-stepping but suffers from far less problems.

–jeroen

PS: Thanks David Heffernan for indicating “Websearch for NTSTATUS. Knowledge of that macro name is the key.”

Posted in Delphi, Delphi XE8, Development, Software Development | 1 Comment »

Reminder to self: check out “Debugging helper for TDataSet” and “debugger TDataSetVisualizer” for Delphi

Posted by jpluimers on 2018/04/24

So I won’t forget to check these out:

Via  [WayBackI like programming in Delphi, but I don’t particularly like writing applications that work with database backends… – Thomas Mueller (dummzeuch) – Google+ (thanks Stefan Glienke)

Read the rest of this entry »

Posted in Delphi, Delphi 10 Seattle, Delphi 2010, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Delphi XE8, Development, Software Development | 1 Comment »

How to embed a superscript Registered symbol in a Rave memo buffer.

Posted by jpluimers on 2018/04/24

Thomas Pfister came with a nice solution to this question:

[WayBack] Does anyone know how to embed a superscript Registered symbol in a Rave memo buffer? – Phillip Woon – Google+

Since Google has such bad indexing of G+, here is the solution:

procedure TForm4.RvSystem1Print(Sender: TObject);
const
  SuperscriptOn = RPTFPrefix + RPTFSuperscript + RPTFOn + RPTFSuffix; // from RpDefine.pas
  SuperscriptOff = RPTFPrefix + RPTFSuperscript + RPTFOff + RPTFSuffix;
var
  MemoBuf: TMemoBuf;
begin
  MemoBuf := TMemoBuf.Create;
  try
    MemoBuf.Text := 'Test' + SuperscriptOn + '®' + SuperscriptOff + ' Test';
    MemoBuf.PrintStart := 0.5;
    MemoBuf.PrintEnd := 8.0;

    with Sender as TBaseReport do begin
      PrintMemo(MemoBuf, 1, true);
    end;
  finally
    FreeAndNil(MemoBuf);
  end;
end;

–jeroen

Source: Does anyone know how to embed a superscript Registered symbol in a Rave memo …

Posted in Delphi, Delphi 10 Seattle, Delphi 10.1 Berlin (BigBen), Delphi 2007, Delphi 2009, Delphi 2010, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Delphi XE8, Development, Software Development | Leave a Comment »

Tip for the doc team: make TMonitor.Enter docs more clear on non-blocking re-entry from the same thread

Posted by jpluimers on 2018/04/19

Even when the Delphi team was large, the documentation was lacking, so with the reduced Delphi team size, I don’t have high expectations of the below to get fixed.

But since much of the post Delphi 7 run-time library looks a lot like the .NET core, you can usually fallback to the Microsoft documentation.

Tip for the doc team: make http://docwiki.embarcadero.com/Libraries/en/System.TMonitor.Enter more clear. Especially that if the same thread calls TMonitor.Enter more than one time, it will allow entry without blocking as per System.Threading.Monitor.Enter Method (Object) documentation https://msdn.microsoft.com/en-us/library/de0542zz

(note that this got introduced in Delphi XE3: http://docwiki.embarcadero.com/Libraries/XE3/en/System.TMonitor.Enter)

–jeroen

via: [WayBack] Tip for the doc team: make http://docwiki.embarcadero.com/Libraries/Seattle/e…

Posted in Delphi, Delphi 10 Seattle, Delphi 10.1 Berlin (BigBen), Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Delphi XE8, Development, Software Development | 2 Comments »

 
%d bloggers like this: