Quantcast
Channel: Planet Object Pascal
Viewing all 1725 articles
Browse latest View live

Andy's Blog and Tools: The Return of the Byte-Strings

$
0
0

Delphi’s NextGen compiler (Android, IOS) removed support for UTF8String, AnsiString and RawByteString. But if you look into System.pas you see that those types are still there but Embarcadero makes them inaccessible from outside of System.pas by prefixing them with an underscore that the compiler converts to the at-sign. And you can’t write “@UTF8String” as it is not a valid identifier.

By patching DCU files it is possible to make those hidden types accessible. And guess what, the compiler generates correct code for the “unsupported” strings.

The unit System.ByteStrings reintroduces:

  • ShortString
  • AnsiString
  • AnsiChar
  • PAnsiChar
  • PPAnsiChar
  • UTF8String
  • PUTF8String
  • RawByteString
  • PRawByteString

Usage:
Add the System.ByteStrings.dcu’s path to the compiler’s search path and add the unit to your uses clauses.

There is no *.PAS file because the DCU is patched with a hex editor to get access to the hidden types.

NameIDE VersionFileSizeDownloadsAdded
System.ByteStringsXE5XE5ByteStrings.7z2.45 KB257 times 2013-10-23

Firebird News: ANN: FB TraceManager V3.0.2 has been released!

$
0
0
Upscene Productions is excited to officially release FB TraceManager V3.0.2! Ever wondered if garbage collection might be guilty when one and the same statement shows dramatic different execution time on the same data volume? We have the answer. This release exposes user-friendly Firebird Garbage Collection information at statement-level in parsed trace data and in the […]

Delphi Haven: FMX/XE5 issue: new ShowModal overload poorly implemented

$
0
0

A few weeks ago Marco Cantù, the Delphi Project Manager, blogged about a new FMX ShowModal overload introduced in XE5. As Marco explained, the reason for this new overload is because a Windows-style ShowModal isn’t possible on mobile platforms. While his blog post met the odd objection in the comments, if anything, a revised ShowModal could have been added from the start – due to deliberate design decisions by Apple, the classic ShowModal isn’t entirely straightforward even on OS X, so Embarcadero have my sympathies.

That said, I’ve found the actual implementation of the new overload problematic. On Windows and OS X, it fails to show the form modally at all (see QC 120024). Moreover, on all platforms, setting the shown form’s ModalResult property (either directly or by setting a button’s ModalResult property) does not close the form like it would do in the classic ShowModal style (QC 120025). To fix these issues, I would suggest Embarcadero do something like the following:

1. Move the ShowWindowModal method from IFMXWindowService into its own IFMXModalWindowService interface. If a platform doesn’t implement classic ShowModal functionality, then it shouldn’t implement the new interface.

2. Change the new ShowModal overload’s implementation to call the classic ShowModal if it is supported:

procedure TCommonCustomForm.ShowModal(const ResultProc: TProc<TModalResult>);
begin
  if Supports(FWinService, IFMXModalWindowService) then
    ResultProc(ShowModal)
  else
  begin
    FResultProc := ResultProc;
    Show;
  end;
end;

3. Amend TCommonCustomForm.SetModalResult to look something like this:

procedure TCommonCustomForm.SetModalResult(Value: TModalResult);
begin
  FModalResult := Value;
  if Assigned(FResultProc) then
  begin
    Close; //!!!added
    FResultProc(FModalResult);
    FResultProc := nil;
  end;
end;

4. Raise an exception in the classic ShowModal’s method body if IFMXModalWindowService isn’t implemented.


Te Waka o Pascal: Platform Ignorants

$
0
0
A while ago Marco Cantu posted about an issue with implementing ShowModal in FireMonkey, specifically with reference to the difficulties this entailed on iOS and Google Android platforms. Chris Rolliston recently picked this same topic up and highlighted some problems that still remain in the FireMonkey “solution”. Both Marco and Chris however have missed a […]

TPersistent: The Wild Wild West

$
0
0

It’s been my experience that Delphi applications are often produced by a single developer or a very small team working largely independently to “get it done”.  You know…no in-line comments, design or requirement documentation, just the code.  Sometimes I have even been told that developers don’t write documentation because the code is self documenting.  While Pascal is very readable for most part there are times you still have to interface with raw APIs, and that code tends to be less readable.  The code itself also never documents assumptions made, how the class instances interact, or reasons for writing things certain ways some of which may no longer apply as RDBMS and other software depended upon, has evolved over time.

Very often these developers are self taught, and there are still many developers actively writing code who started before object oriented programming came into vogue, and design patterns, TDD and other software development best practices became known and proven (I’m one).

Sometimes people continue to develop in ways they are comfortable with, and are understandably more concerned about “getting it done”, than “doing it right”, or they simply haven’t taken the time necessary to hone their skills.  The problem is that eventually they code themselves into a corner where they can’t easily make any changes without risking breakage, and major changes require a rewrite because the code is so tightly bound together.  This “technical debt” can creep up rather quickly when you have cowboy coders, or management that is always pressing for new development to expand the business, and doesn’t understand that payments against technical debt must be made.

Just like the real world, the world of software development has become much more civilized.  You can start a product with cowboy coders, but the moment you want to build a company around it you need resources, and the cowboy coding methods just don’t work in a team environment.  Teams need documentation to disseminate information without requiring a senior (more experienced with the code) member to teach more junior ones (not necessarily junior in terms of technical skills).  This causes a kind of paralysis as you try to grow the team, resulting in significantly higher declining rates of return for the investment in new developers.

It’s never too late to change your ways, and turn in your six gun.  I am reading Working Effectively with Legacy Code by Michael Feathers, and although I’m not that far into it, I would already recommend it.

DelphiTools.info: Efficient String Concatenation in Delphi

$
0
0
You may all know about String concatenation in Delphi, but do you know about the implicit String variables the compiler may create for you? Along with the implicit variables come implicit exception frames, and a whole lot of hidden stack juggling, which can quickly become hidden complexity bottlenecks. Looking Innocent What’s more innocent-looking than a…

Te Waka o Pascal: Improved Quality in Delphi – Yeah Right

$
0
0
Here in Aotearoa there is a beer company called “Tui”, named in turn for a native bird. As well as a series of TV ads voiced by the great Tom Baker, Tui are famous here for their “Yeah, right!” billboard ads. I felt compelled to make one for Delphi. I am currently working on preparing […]

Delphi Haven: FMX menu unfurling speed

$
0
0

A bit ago I posted a QC report complaining about the speed at which a nested FMX popup menu unfurls. Steps:

  1. Create a new FMX desktop application.
  2. Add a TPopupMenu to the form, then four items to the popup menu, the second parented to the first, the third to second and the fourth to the third.
  3. Add a TRectangle to the form and assign its PopupMenu property to PopupMenu1.
  4. Right click on the popup menu, select the first item then hover over the second; once the third item is shown, hover over it to show the fourth.

Expected: the menu unfolds quickly.
Actual: the menu unfolds sloooowly.

At the time I thought FMX menus were just slow… until it recently got pointed out to me that the FMX source in fact hardcodes a delay of 500ms. As such, if you require quickly unfurling menus, just take a copy of FMX.Menus.pas and change the value assigned to FDelay in the constructor for TAutopopupMenuTimer (line 575 in XE5 RTM).

That said, ideally, the correct value would be got from the OS; for Windows, the API function to call is SystemParametersInfo:

uses
  WinApi.Windows;

function GetMenuShowDelay: Integer;
var
  Value: DWORD;
begin
  SystemParametersInfo(SPI_GETMENUSHOWDELAY, 0, @Value, 0);
  Result := Value;
end;

To be honest, I’m not sure what the OS X equivalent (if there is one) is, so if anyone knows, feel free to tell all in the comments…



Delphi Haven: XE5 update 1 is out

Andreano Lanusse | Technology and Software Development: Delphi XE5 Update 1 fixes for serious issues on ClientDataSet

$
0
0

The Update 1 for Delphi XE5 and C++Builder XE5 has been released.

This update touch some areas like FireDAC, FireMonkey, Debugger, IDE and mainly ClientDataSet. Below a list of fixes related to ClientDataSet, which I consider critical errors and a blocker for anyone that was looking to migrate to XE5.

Quality Central Reference No.SummaryComponent/s
118951Numeric Filters on a TClientDataSet do not filterData, Data\Midas
119028Linker error: TXMLTransformProvider libraries missingData, Data\Midas
119164Attempting to use MIDAS (eg TClientDataset) in the simulator on iOS7 failsData, Data\Midas
119432TClientDataSet.Locate method fails to work properly with XE5 midas.dllData, Data\Midas
 Application stops when driver is missingData, Data\FireDAC
 [Phys]-300 on connecting using Oracle / MSSQL / etc drivers using Arch SKU at design-timeData, Data\FireDAC

 

For a complete list of the specific problems fixed in this update, click here.

Download Links

You can download the update 1 installer or a new fresh ISO that includes Update 1:

That’s is, have fun.

Andreano Lanusse | Technology and Software Development
Follow me on Twitter: @andreanolanusse

The Wiert Corner - irregular stream of stuff: jpluimers

$
0
0

Toon Krijthe posted an interesting question to SO.

Though 5 years old, I think it stilll is very valid one:

At my work, we have decided to stay with the ANSI characters for identifiers. Is there anybody out there using unicode identifiers and what are the experiences?

For all projects I work on (in various Languages like  English, German, Dutch or other), I stick to ASCII characters (not even ANSI) for:

  • file names
  • identifiers

I also try to abstract the non-ASCII strings into places where I am sure that the encoding is preserved (for text files, I prefer UTF-8), or where these characters are properly escaped.

What is your take on this?

–jeroen

via: uniqueidentifier – What are the experiences with using unicode in identifiers – Stack Overflow.


Filed under: .NET, Agile, AS/400 / iSeries / System i, C, C#, C++, COBOL, Continuous Integration, Delphi, Development, F#, Prism, Scripting, Software Development, VB.NET, Visual Studio and tools

Te Waka o Pascal: Build Automation With Train

$
0
0
A comment from Kevin P brought a build automation tool to my attention this evening, called Train. Train is a JavaScript based build automation tool from a little company called RemObjects. It is written in Oxygene but the API provides specific support for Delphi. It’s an open source project and free (as in beer). So […]

Daniel Magin's Logfile: PAServer now with Verbose XE5 Update 1

$
0
0

Embarcadero has deployed update 1 for RadStudio/Delphi/C++Builder

LINK

On cool new feature is the verbose feature in the PAServer. After starting the server you type "v" for verbose. Now you can see all command lines during deployment process. If some is failed you can easy recall the command again in terminal with copy paste to see more detail informations.

Great Thanks EMB !!!

verbose_PAServer 

Delphi Code Monkey: Delphi Experts and IDE Plugins I Love Part 3: Model Maker Code Explorer

$
0
0
ModelMaker Code Explorer is one of two Delphi add-ons that is commercial that I usually buy, the other is MadExcept.   In part four, I will try Castalia, which has a loyal following as well.  But given the choice between the two, I like ModelMaker Code Explorer.



The main things I like about it are:


  • It has the best Class Browser and navigation and structure-view features of any Delphi IDE plugin.  Some of the features that I came to love in Xcode, which are also in GExperts but in less complete fashion, are built into the class browser and navigation features of MMX.
  • One feature that I use all the time is the Uses Clause formatter.  I like my uses-clauses one-per-line because it decreases the incidence of merge conflicts when people just insert units into the middle of complex uses-clause declarations.  It's also useful for when you group your units into sections, as I often do.    Once I have grouped dependencies, the structure of my system becomes clearer.  This is a precursor to making the design simpler, or easier to test, or otherwise better.  Perhaps if your uses clause takes up 300 lines of code, it might help you realize you're building a big ball of mud and that you should start cleaning it up, instead of making it worse every day you work on the code.
before

after (MMX + some manual work)


  • Another is a feature under "Text Tools", that will take something you paste from the clipboard and format it as a multi line string literal. For example, I often use it to take SQL that I wrote in SQL Management Studio and paste it into a .pas unit, as a multi-line string literal. Because Delphi lacks and easy "here-document" syntax (like the triple-quote syntax of Python), this is a considerable time-saver.
  • It contains a lot of good refactoring features that the base IDE cannot do, but I actually hardly use any of these. Instead, I find the "live metrics" and other "analysis" features, which shows "stuff which needs fixing or attention" is far more useful. I tend to leave a lot of TODO items around, and while Delphi contains a TODO feature, having that panel open is a waste of space. But having one panel with a comprehensive list of areas that need attention is much more useful to me.   "Metrics" is a poor name choice, in my opinion, it's more of a "Lint" feature.  Lint is a term from the C programming world that means "additional style warnings", that can help you find problems.  While nowhere near as comprehensive as the features in Pascal Analyzer, MMX's "Metrics" features are like a second level of live hints and warnings. Since the live hints and warnings in Delphi often misbehave, I often leave "Error Insight" turned off in Delphi and use MMX instead.  The Event Handler Analysis feature has found dead code for me, and event handlers which have become "unhooked" due to accidental editing, which is a bug that RAD tools like Delphi are vulnerable to.   Delphi is far behind Xcode, Visual Studio, and most Java IDEs in its Lint/Hint/Warning features, but tools like MMX really help bring it up to speed.


  • I have learned a lot from reorganizing my large classes. For example, sorting the methods and properties in a mega-class, is often a good precursor to breaking up the class into a series of smaller, much better designed classes.  Having all the methods that start with "open" sorted beside each other, for example, might lead me to consider that having five methods named "openThis", "openThat", and "openTheOther" leads me to wonder why I have another method called "makeViewForSomething".  maybe I should rename that to "openSomething", since it would make more obvious sense than what I had before. What was I thinking when I called that "makeViewForSomething"?  Or if there was some reason why "makeView" was a better name, maybe all the "open" methods should have been "makeView" methods.   Thinking about whether or not the stuff in your method names makes sense, and is consistent or inconsistent is made easier, when you organize your classes and units.
Like many Delphi add-ons and tools, this one also has a free trial.  I highly recommend you download it and try it.  Perhaps the best feature of MMX, is that the guy who makes it, Gerrit Beuze, provides top-tier technical support for his products. If you find a bug, he'll generally fix it pretty fast.  I've been completely impressed with how he handles support and bug fixes.   A wonderful product, something I find it hard to live without now.


Behind the connection: Delphi XE5 update 1 is available

$
0
0
You already know that the update is available if you turned on auto-updates in your Delphi setup. If you didn't, now you know there is a new update... Delphi and C++Builder XE5 Update 1 is available as an MSI patch or an ISO. You can also download the update from the registered users web page. -- Follow me on Twitter Follow me on LinkedIn Follow me on Google+ Visit my website: http://

Te Waka o Pascal: Best Comment In The History of … well Ever (for ALL values of Ever) ?

$
0
0
In the comments on Raymond Chen’s blog post today, was a reference to a startling question on Stack-Overflow. As if the question itself wasn’t (unintentionally) amusing enough, the accepted answer demonstrates a commitment to lost causes that is truly inspired and contains a number of (intentional and very clever) laugh out loud moments for developer […]

Firebird News: Firebird ActiveRecord adapter 0.7.8 for Rails 3.2+ marked as stable

$
0
0
Although this adapter may not yet have feature parity with the 1st tier databases supported by the Rails developers, it has been in production for several months without issues (Rails 3.2.x) and may be considered stable. (Rails 4 testing and pull requests are wellcome)

DelphiTools.info: Efficient String Building in Delphi

$
0
0
As a followup to the String Concatenation article, let’s take a look at a less trivial case: what if instead of concatenating a couple strings, you want to concatenate a few hundred? Sounds like a task at which TStringBuilder should excel, but one should never assume, and always measure. Eating Lots of Apples While some…

DelphiTools.info: Pimp your WebSite with an Halloween Bat

$
0
0
Time for some Halloween silliness: here is a quick & dirty JavaScript to pimp your website, blog or whatever with a randomly moving vampire bat animation. Or a dozen. Or a whole flock. jsbat.js (v1.2 just 1.9 kB) Installing Download the file to your website or feel free to link it here. Then add as many…

The Wiert Corner - irregular stream of stuff: jpluimers

$
0
0

The question datetime – Delphi Now() function returns a wrong value – Stack Overflow is similar to my article Delphi – Michael Justin had strange floating point results when his 8087 FPU Control Word got hosed.

Good that stackoverflow user Anton Zhuchkov found out the cause himself: his answer indicates the Precision Control (and rounding) part of the FPU state got hosed by wrongly initializing the Direct3D device.

I edited his answer with some extra links to documentation.

Finally I’ve found the solution. I needed to specify the D3DCREATE_FPU_PRESERVE flag when creating a D3D device by D3D.CreateDevice.

Otherwise, without that flag, all floating point operations are performed with single precision. As the TDateTime is a simple Double, and Now() functions is consist of simple addition of date value to time value, it all get messed up by DirectX “smart” override.

Problem solved. It was a tricky one indeed. :)

–jeroen

via: datetime – Delphi Now() function returns a wrong value – Stack Overflow.


Filed under: Delphi, Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi 5, Delphi 6, Delphi 7, Delphi XE, Delphi XE2, Delphi XE3, Development, Software Development
Viewing all 1725 articles
Browse latest View live