News, Blogs, and Tips

RAD Studio 10.2.2 Tokyo February 2018 Patch Re-Released

Marco Cantu - Fri, 02/16/2018 - 01:21

Last week, Embarcadero released a patch for Tokyo 10.2.2, focused on Android and RTL improvements. What happened is that Windows would not always ask for execution with admin account (on systems with active User Account Control) and could end up copying the replacement files in a wrong location. It did affect a few of the developers who tried it, so we pulled it, fixed the installer and now re-issued the patch.

If you are a registered user of Tokyo (or have a license for it), you can find it at https://cc.embarcadero.com/item/30819.

There is no change in the content on the patch, so if you already installed it successfully, there is no need to repeat the process. On the other hand, if your installation got broken, we have provided an alternative ZIP-based option (in the same download page). We have already sent it to developers who had got in trouble, but might not have reached everyone.

As for the content, the main fix is the Android animations and tab animation issue. These have been addressed. There are still cases in code where the combination of called to Application.ProcessMessages and timers might get you in trouble. I'll blog more information ASAP, but the general recommendation is to use threads rather than timers for background processing -- an all platforms, although in Windows that coding style can be used.

Categories: News, Blogs, and Tips

Delphi 23 and Delphi 10.2.3

Marco Cantu - Wed, 02/14/2018 - 13:05

Today is Delphi's 23rd birthday. The product was launched on Valentine day in 1995 in San Francisco (and I had the luck to be there, as I covered in the past). 23 years is a lot of time for people. It is a incredibly long time for technologies. It is hard to find a language, framework and IDE from 23 years ago you can use to build todays's and tomorrow's software. Of course, the IDE, language and frameworks have evolved and keep evolving -- developers using them can modernize their apps without a full rewrite.

In this 23 years, millions of developers and have used Delphi to build millions of applications, and applications used by millions of users. The most used Delphi application ever build is probably Skype for Windows. But it has been used to build applications worth millions in sales and moving millions in financial markets. And Delphi is still used to day to maintain those applications and create new ones in industrial, financial, health, travel, and sport fields (among others)... including mobile apps for its birthday. Or to run a miniature airport.

In these 23 years the product has changed a lot (Hey, I've changed a lot from the picture in the link above!), Below you can find a comparison of Delphi 1 running on a VM and Delphi 10.2.2 (with dark theme) running on the same machine. It is not a Photoshop, it is an actual screenshot!

Both versions of the IDE have a VCL application with a Button and the Caption property highlighted in the Object Inspector. I didnt' include the about bos of 10.2.2 (as I was trying to do) because it is a little too big. One of these days I'll make a parallel video of working on both. But you know what? Most applications you build in Delphi 1 can be recompiled with few changes in the 23 year later version. Well, as long as you don't use pointers, as Delphi 1 had 16 bit pointers (ugh!). Of course, most applications you write in todays product don't have a chance to run in the older sibling.

Speaking of today, Embarcadero (and the PM team I'm part of) just announced some more plans for this year, and the plan does include the coming release of an additional quality focused update for 10.2 Tokyo, 10.2.3. Now 10 x 2 + 3 is in fact 23. Or Delphi 10 version 2.3. We have a lot in the works for the next mayor release, but also want to keep improving on the quality of Tokyo and release it as soon as possible.

What else can I say? Just invite to you watch Jim Mckeeth great "23 years" Why I Love Delphi video.

Categories: News, Blogs, and Tips

My New RTTI in Delphi Class on Embarcadero Academy

Marco Cantu - Mon, 02/05/2018 - 01:43

As you might remember, I'm helping building the Delphi curricula on the Embarcadero Academy web site. My focus so far has been on the Delphi language, while other tackle VCL and other areas, or other languages and tools. Last week I completed my set of classes on the Modern Delphi language (Interfaces, Generics, Anonymous Methods) with a class on reflection and RTTI. You can buy each of these classes separately (price vary depending on the length) or buy the complete bundle with over 8 hours of content.

The class on reflection and RTTI has a lot of information on the modern RTTI (compared to the classic one), covers the RTTI unit, the TValue record, the use of attributes and much more. And for those who already purchased the Modern Delphi bundle in th past, the new class has been added to their account for free!

Categories: News, Blogs, and Tips

Try-Finally Blocks for Protecting Multiple Resources in Delphi

Marco Cantu - Fri, 01/26/2018 - 08:52

The Delphi language shares with many others a standard resource allocation pattern to make sure that in case of an exception the resources is properly released. Resources in this context are memory objects, files, operating system objects and handles, and the like. In Delphi, compared to other languages with a garbage collector, the relevance increased by memory management considerations.

Protecting a Single Object

In the most simple cases, you'd write code like:

allocate resource try use resource finally free resource end;

A more specific example would be like:

A1 := TTest.Create; try A1.DoSomething; finally A1.Free; end;

So far, so good. Notice that is an error happen during the constructor execution, Delphi will automatically execute the destructor for the partially initialized object (but this could be a topic for another blog post).

Protecting Two Objects: How NOT to Write the Code

The issue I want to focus on is how to write the same type of code if you need to allocate and dispose two resources. Here there are multiple options. What you shouldn't do (but is fairly common) is to write:

A1 := TTest.Create; A2 := TTest.Create; try A1.DoSomething; A2.DoSomething (A1); finally A2.Free; A1.Free; end;

The issue with this code is that in case the creation of A2 fails (and there could be many reasons), the A1 object would remain in memory. Simply pushing the second allocation within the try block is also not good:

A1 := TTest.Create; try A2 := TTest.Create; A1.DoSomething; A2.DoSomething (a); finally A2.Free; A1.Free; end;

With this code in case of a failure in object A2 constructor call, the finally block will try to Free an uninitialized object (the default value of a local object reference is undefined). This is why a possible solution is to set A2 to nil at the beginning -- as calling Free on a nil object has no effect. Or set all object reference to nil for simplicity and uniformity. Or write two nested try blocks to protect each of the resources.

Protecting Two Objects: A Tale of Three Solutions

This long introduction brings us to the point of this blog post. There are at least 3 different correct solution for the issue of protecting two resources in the same code block, as I just mentioned. Here are the three solutions in an image I "borrowed" from one of our RAD Studio R&D architects, Bruneau Babet.

Provided they are all correct in terms of proper resource management in all scenarios, which are the advantages and disadvantages of these 3 solutions? What is important to consider is that the 2 resources could be 3, or 4 or half a dozen. 

Which One to Pick?

The first solution with the nested try blocks fairly clean but more verbose (more lines of code) and has additional nesting that could become an annoyance with multiple resources. Also, there is a runtime cost associated with try blocks, clearly limited but not zero. 

The second solution has the least amount of lines of code code and the least amount of runtime cost. The only additional is setting A2 to nil. The code remains readable also with many resources. However, the code is "unbalanced" and it might be slightly confusing.

The third solution goes in the same direction, but it adds one extra technically useless assignment to nil (for A1), offering the advantage of being cleaner and more balanced, and likely more readable after all.

So what's the best solution? This is really hard to tell,. I personally mostly used #1 in my books, but at Embarcadero we tend to prefer the cleaner and faster ones (that is, #2 or #3) for library code. Interested in your opinions, of course.

Categories: News, Blogs, and Tips

IDE Fix Pack 6.2

Andy’s Blog and Tools - Thu, 01/25/2018 - 11:32

Delphi 10.2 Tokyo changed how the files for units that are explicitly specified in the project file (dpr/dpk) are found. The IDE Fix Pack’s directory file search cache still made assumptions that were correct in Delphi 2009-10.1 Seattle but aren’t in Tokyo. This could result in an “program or unit xxx recursively uses itself” error messages if you had a relative path in the filename that is specified in the project file.

This release also adds another option to the compiler codegen optimizations. The new -x-orc / -x-orc=n option allows you to eliminate temporary record copies for functions like “begin Result := FRedirect.GetRecord; end;”. This optimization allows the compiler to skip the try/finally block with InitializeRecord/CopyRecord/FinalizeRecord calls for the temporary record variable that is then copied to the actual result record.

  • Fixed: Directory search cache failed if project units had “..\” in it (Delphi 10.2 only)
  • Fixed: Some VirtualProtect calls specified nil as last argument what Windows 10 1709 doesn’t like if a debugger is attached.
  • Added: Option -x-orc and -x-orc=n to remove temporary record variables for function results (n=1: only if the assignment is the last statement, n=2 for all)

Download:

Name IDE Version File Size Downloads Added IDE Fix Pack 6.2 2009 (UP4) IDEFixPack2009Reg62.7z 189.91 KB 31 times 2018-01-25 IDE Fix Pack 6.2 2010 (UP5) IDEFixPack2010Reg62.7z 186.64 KB 39 times 2018-01-25 IDE Fix Pack 6.2 XE (UP1) IDEFixPackXEReg62.7z 173.99 KB 41 times 2018-01-25 IDE Fix Pack 6.2 XE2 (UP4+HF1) IDEFixPackXE2Reg62.7z 259.6 KB 47 times 2018-01-25 IDE Fix Pack 6.2 XE3 (UP2) IDEFixPackXE3Reg62.7z 213.96 KB 26 times 2018-01-25 IDE Fix Pack 6.2 XE4 (UP1) IDEFixPackXE4Reg62.7z 216.45 KB 26 times 2018-01-25 IDE Fix Pack 6.2 XE5 (UP2) IDEFixPackXE5Reg62.7z 213.86 KB 28 times 2018-01-25 IDE Fix Pack 6.2 XE6 (UP1) IDEFixPackXE6Reg62.7z 374.48 KB 27 times 2018-01-25 IDE Fix Pack 6.2 XE7 (UP1) IDEFixPackXE7Reg62.7z 391.04 KB 41 times 2018-01-25 IDE Fix Pack 6.2 XE8 (UP1) IDEFixPackXE8Reg62.7z 389.48 KB 29 times 2018-01-25 IDE Fix Pack 6.2 10 Seattle (RTM/UP1) IDEFixPackD10Reg62.7z 397.96 KB 54 times 2018-01-25 IDE Fix Pack 6.2 10.1 Berlin IDEFixPackD101Reg62.7z 396.17 KB 97 times 2018-01-25 IDE Fix Pack 6.2 10.2 (RTM/UP1/UP2) IDEFixPackD102Reg62.7z 397.04 KB 315 times 2018-01-25

Download (fastdcc for the command line compiler):

Name IDE Version File Size Downloads Added fastdcc 6.2 2009 (UP4) fastdcc2009v62.7z 83.87 KB 14 times 2018-01-25 fastdcc 6.2 2010 (UP5) fastdcc2010v62.7z 91.24 KB 13 times 2018-01-25 fastdcc 6.2 XE (UP1) fastdccXEv62.7z 92.96 KB 19 times 2018-01-25 fastdcc 6.2 XE2 (UP4+HF1) fastdccXE2v62.7z 130.93 KB 19 times 2018-01-25 fastdcc 6.2 XE3 (UP2) fastdccXE3v62.7z 139.67 KB 13 times 2018-01-25 fastdcc 6.2 XE4 (UP1) fastdccXE4v62.7z 142.06 KB 11 times 2018-01-25 fastdcc 6.2 XE5 (UP2) fastdccXE5v62.7z 141 KB 12 times 2018-01-25 fastdcc 6.2 XE6 (UP1) fastdccXE6v62.7z 187.93 KB 12 times 2018-01-25 fastdcc 6.2 XE7 (UP1) fastdccXE7v62.7z 202.69 KB 18 times 2018-01-25 fastdcc 6.2 XE8 (UP1) fastdccXE8v62.7z 202.58 KB 14 times 2018-01-25 fastdcc 6.2 10 Seattle (RTM/UP1) fastdccD10v62.7z 202.74 KB 19 times 2018-01-25 fastdcc 6.2 10.1 Berlin fastdccD101v62.7z 202.48 KB 28 times 2018-01-25 fastdcc 6.2 10.2 (RTM/UP1/UP2) fastdccD102v62.7z 202.34 KB 71 times 2018-01-25
Categories: News, Blogs, and Tips

HTTP Protocol Related Improvements in Delphi 10.2.2

Marco Cantu - Wed, 01/24/2018 - 07:11

The new features for the HTTP client library offer more flexibility and options in terms of protocol and standards support. 

Better Secure Protocols Support

The first change is the improved support for security protocols. In the past it wasn't possible to specify the required security protocols (TLS1.1, TLS1.2, etc.) for an HTTP request. We have added a new enumeration, THTTPSecureProtocol with the values (SSL2, SSL3, TLS1, TLS11, TLS12). THPPTClient and related classes have now a SecureProtocols property which is a set based on that enumeration.

The property (available only at run-time) controls which security protocols to use and it is currently implemented only for Windows. This was requested in our Quality Portal at https://quality.embarcadero.com/browse/RSP-18713

HTTP Redirect Improvements

Another set of improvements is in the way the HTTP client library handles redirects. There is a new RedirectsWithGET runtime property offering another set of options, this time based on the following enumeration:

THTTPRedirectWithGET = (Post301, Post302, Post303, Post307, Post308,   Put301, Put302, Put303, Put307, Put308, Delete301, Delete302,   Delete303, Delete307, Delete308);

The property controls which request method and response status must be redirected using GET method and it was reported in several entries in QP, including https://quality.embarcadero.com/browse/RSP-14671.

New REST Client Events OnNeedClientCert and OnAuthEvent

These events corresponds to their HTTPClient counterparts and are now surfaces at a higher level:

TRESTClient.OnNeedClientCertificate: TNeedClientCertificateEvent TRESTClient.OnAuthEvent: TCredentialAuthEvent

This was requested in https://quality.embarcadero.com/browse/RSP-15857

MIME Name Helper

We added a function that to the TEncoding support, which returns the encoding MIME for a speficied encoding:

function GetEncodingMimeName(AEncoding: TEncoding): string; Changed TIniFile Behaviour

This one is totally unrelated, beside the fact it was also done in 10.2.2. The Ini File behavior was platform specific, not is it platform independent. On Windows, TIniFile ReadString ignores the case of Key parameter. On Linux, the ReadString call was case sensitive, leading to issues when migrating code and configuration files. Now by default TIniFile content structure (not the actual values) is treated in a case-insensitive way on all supported platforms.

Categories: News, Blogs, and Tips

My Year in Cities 2017

Marco Cantu - Sun, 12/31/2017 - 08:45

This is my end-of-the-year blog post listing places I've visited in 2017 for at least one night (plus some relevant daily trips, marked with an asterisk), in chronological order. At times, the reason for the trip is listed: 

Torino (Italy)*

Trento (Italy)*

Sydney (Australia)

Brisbane (Australia), ADUG conference

Melbourne (Australia), ADUG conference

Altdorf (Switzerland)

Sprendlingen (Germany)

Nieuwegein (Netherlands)

Amsterdam (Netherlands)

Texel Island (Netherlands)

Nieuw Vennep (Netherlands)

Rotterdam (Netherlands)

Bruxelles (Belgium)

Vincey (France)

Colmar (France)

Berlin (Germany)

Zegrze (Poland), Delphi conference

Pisa (Italy)*

Frascati (Italy), ITDevCon conference

Koln (Germany), EKON conference

Viareggio (Italy)

Lucca (Italy)*, Lucca Comics event

Katowice (Poland)*

Ravenna (Italy)*

While I've been traveling a bit, my trips this year have been limited to Europe, plus a long trip to Australia. Planning a trip to the US within a few weeks, and spend some time booking flights today. Good sign.  

Have a great 2018 full of health and happiness (and traveling!).

Categories: News, Blogs, and Tips

Moving DNS, Some Hiccups Expected

Marco Cantu - Mon, 12/18/2017 - 09:48

Not much to add. I'm (finally) changing my registrar and DNS provider. Hope everything goes smootly, but it might be that the site and blog are not working in the few coming days. The physical server is not moving, so there should be no big trouble.

Categories: News, Blogs, and Tips

DataSet Mapping to JSON for JavaScript client support in RAD Studio 10.2.2

Marco Cantu - Fri, 12/15/2017 - 02:45

RAD Studio has offered support for JSON in different ways and for a long time. From the JSON system unit (originally part of the DBX space) to the old DataSnap table mapping (also via DBX) and to FireDAC tables to JSON mapping, there are many ways to interact with JSON data structures. However, until the most recent release, we lacked a way to map a dataset to a custom JSON structure -- the FireDAC JSON support produces a FireDAC specific structure, with meta data and record status information.

While this is a gap we already wanted to fill, it become more important to address it now that we are pushing RAD Server (a free deployment license is included with 10.2.2 Enterprise and above) and use it as a backend for ExtJS applications. As you can read in my blog post Implementing AJAX and JSONP Support in RAD Server for ExtJS, while this works the dataset mapping to JSON required writing custom code. Our first step in simplifying the use of Delphi as a backend for JavaScript applications is offering a better way to produce the JSON data from a database table.

While we have build this support for the scenario of using RAD Server, FireDAC, and ExtJS, the same component and technology can be used for any web service architecture written in Delphi and C++Builder (even pure and simple WebBroker), any dataset other than FireDAC, and any JavaScript client. It is a completely open and a fairly flexible solution. But it certainly works great for our specific scenario!

A VCL Application

I'll describe the solution using two demos. The first is a plain VCL application. while the second will be a RAD Server package. This highlights the fact that the solution is fairly general. In the first demo, I have the following components on a form (I know, I should have used a data module...):

This is the configuration of the components:

object EmployeeConnection: TFDConnection Params.Strings = ( 'ConnectionDef=EMPLOYEE') end object EmployeeTable: TFDQuery Connection = EmployeeConnection SQL.Strings = ( 'SELECT * FROM EMPLOYEE') end object FDBatchMoveDataSetReader1: TFDBatchMoveDataSetReader DataSet = EmployeeTable end object FDBatchMoveJSONWriter1: TFDBatchMoveJSONWriter DataDef.Fields = <> end object FDBatchMove1: TFDBatchMove Reader = FDBatchMoveDataSetReader1 Writer = FDBatchMoveJSONWriter1 Mappings = <> LogFileName = 'Data.log' end

With this configuration in place, all you need to do to produce the JSON is connect the output to the JSON writer and execute the batch move operation. In this case I've used a stream:

procedure TForm5.Button1Click(Sender: TObject); var sstr: TStringStream; begin sstr := TStringStream.Create; try EmployeeTable.Active := True; FDBatchMoveJSONWriter1.Stream := sstr; FDBatchMove1.Execute; ShowMessage (sstr.DataString); finally sstr.Free; end; end;

Other options are assigning to the writer for the output a JSONWriter (as I'll show shortly) or a JSONArray.

A RAD Server Web Service

For the second demo, the RAD Server demo, I've used the same set of components with the same configuration. In this cases I've added to an EMS package an "employee" resource, and implemented its get operation with the following stream-based code:

procedure TEmployeeResource1.Get(const AContext: TEndpointContext; const ARequest: TEndpointRequest; const AResponse: TEndpointResponse); var mStream: TMemoryStream; begin mStream := TMemoryStream.Create; AResponse.Body.SetStream(mStream,'application/json', True); FDBatchMoveJSONWriter1.Stream := mStream; FDBatchMove1.Execute; end;

As a better and simpler alternative, I could have used the JSONWriter property. The difference is that rather tha building the entire JSON data structure in the memory stream and later copy it to the HTML response, the data is written directly to the HTML response, reducing the work and the memory consumption:

procedure TEmployeeResource1.Get(const AContext: TEndpointContext; const ARequest: TEndpointRequest; const AResponse: TEndpointResponse); begin FDBatchMoveJSONWriter1.JsonWriter := AResponse.Body.JSONWriter; FDBatchMove1.Execute; end;

In both cases, you'll see an output like the following:

This is only a first initial step of the support we are planning to simplify the use of Delphi and RAD Server as backend for JavaScript and ExtJS applications. More support will be made available soon. Stay tuned.

Categories: News, Blogs, and Tips

IDE Fix Pack 6.1.2 (supports Delphi 10.2.2)

Andy’s Blog and Tools - Thu, 12/14/2017 - 15:11

A small update for IDE Fix Pack that adds support for the just released Delphi 10.2.2.

  • Added: Support for Delphi 10.2 Update 2
  • Added: Fix for unnecessary temporary variable if an empty open array argument is part of a function call (Delphi 2009-10.1)

Download:

Name IDE Version File Size Downloads Added IDE Fix Pack 6.2 2009 (UP4) IDEFixPack2009Reg62.7z 189.91 KB 31 times 2018-01-25 IDE Fix Pack 6.2 2010 (UP5) IDEFixPack2010Reg62.7z 186.64 KB 39 times 2018-01-25 IDE Fix Pack 6.2 XE (UP1) IDEFixPackXEReg62.7z 173.99 KB 41 times 2018-01-25 IDE Fix Pack 6.2 XE2 (UP4+HF1) IDEFixPackXE2Reg62.7z 259.6 KB 47 times 2018-01-25 IDE Fix Pack 6.2 XE3 (UP2) IDEFixPackXE3Reg62.7z 213.96 KB 26 times 2018-01-25 IDE Fix Pack 6.2 XE4 (UP1) IDEFixPackXE4Reg62.7z 216.45 KB 26 times 2018-01-25 IDE Fix Pack 6.2 XE5 (UP2) IDEFixPackXE5Reg62.7z 213.86 KB 28 times 2018-01-25 IDE Fix Pack 6.2 XE6 (UP1) IDEFixPackXE6Reg62.7z 374.48 KB 27 times 2018-01-25 IDE Fix Pack 6.2 XE7 (UP1) IDEFixPackXE7Reg62.7z 391.04 KB 41 times 2018-01-25 IDE Fix Pack 6.2 XE8 (UP1) IDEFixPackXE8Reg62.7z 389.48 KB 29 times 2018-01-25 IDE Fix Pack 6.2 10 Seattle (RTM/UP1) IDEFixPackD10Reg62.7z 397.96 KB 54 times 2018-01-25 IDE Fix Pack 6.2 10.1 Berlin IDEFixPackD101Reg62.7z 396.17 KB 97 times 2018-01-25 IDE Fix Pack 6.2 10.2 (RTM/UP1/UP2) IDEFixPackD102Reg62.7z 397.04 KB 315 times 2018-01-25

Download (fastdcc for the command line compiler):

Name IDE Version File Size Downloads Added fastdcc 6.2 2009 (UP4) fastdcc2009v62.7z 83.87 KB 14 times 2018-01-25 fastdcc 6.2 2010 (UP5) fastdcc2010v62.7z 91.24 KB 13 times 2018-01-25 fastdcc 6.2 XE (UP1) fastdccXEv62.7z 92.96 KB 19 times 2018-01-25 fastdcc 6.2 XE2 (UP4+HF1) fastdccXE2v62.7z 130.93 KB 19 times 2018-01-25 fastdcc 6.2 XE3 (UP2) fastdccXE3v62.7z 139.67 KB 13 times 2018-01-25 fastdcc 6.2 XE4 (UP1) fastdccXE4v62.7z 142.06 KB 11 times 2018-01-25 fastdcc 6.2 XE5 (UP2) fastdccXE5v62.7z 141 KB 12 times 2018-01-25 fastdcc 6.2 XE6 (UP1) fastdccXE6v62.7z 187.93 KB 12 times 2018-01-25 fastdcc 6.2 XE7 (UP1) fastdccXE7v62.7z 202.69 KB 18 times 2018-01-25 fastdcc 6.2 XE8 (UP1) fastdccXE8v62.7z 202.58 KB 14 times 2018-01-25 fastdcc 6.2 10 Seattle (RTM/UP1) fastdccD10v62.7z 202.74 KB 19 times 2018-01-25 fastdcc 6.2 10.1 Berlin fastdccD101v62.7z 202.48 KB 28 times 2018-01-25 fastdcc 6.2 10.2 (RTM/UP1/UP2) fastdccD102v62.7z 202.34 KB 71 times 2018-01-25
Categories: News, Blogs, and Tips

New VCL Panels in Delphi 10.2.2

Marco Cantu - Thu, 12/14/2017 - 13:47

With the need to support more screen resolutions, while creating nice looking user interfaces and pleasant user experiences, we think it is important to offer additional ways to build the UI of your VCL applications. This is why in 10.2.2 we introduced two new VCL panel controls. These are control containers with specific way to manage the layout and position of their child controls. You can see the controls at design time below:

TCardPanel

The CardPanel control is a set of pages, like the old PageControl, with no tabs. You display one page at a time, and it has built in support for swiping pages using a gesture. It is a collection of panels of the same size, each hosting its own controls.

At design time, you can use the local menu to add a card or select one, as shown here (image courtesy of RAD Studio DocWiki):

Each page is a "TCard" object, which is just a regular panel in disguise, so no special properties of configuration. More information at http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Using_the_Card_Panel_Component

TStackPanel

The stack panel is a panel with a special layout. All controls added to it are placed in a different "row" (or column if you set it horizontally). The controls can be aligned to the left, the right, the center or use the entire space (fill). You set the default alignment at the stack panel level, and you can override it for each individual control (or use the special default value to pick the parent control setting). Each of the controls hosted by the panel, gets three additional properties "injected" by the container -- at the bottom of the Object Inspector list -- as you can see below:

More information at http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Using_the_Stack_Panel_Component

The VCL remains a central pillar of Delphi (and C++Builder), and Embarcadero is and will continue to enhance it matching the evolution of the Windows platform and user experience, while on the other hand ensuring a very high degree of compatibility with the existing VCL code.

Categories: News, Blogs, and Tips

Debugging Delphi Apps on Android 8.1 Works

Marco Cantu - Thu, 12/14/2017 - 03:52

When Google introduced Android 8 this summer, they increased the platform security but happened to block socket access to the debugger, basically preventing debugging applications on a device. You'd see the error message "Can't open socket: Permission denied." as reported also at https://quality.embarcadero.com/browse/RSP-18992. The issue was not a change in out debugger support, but a problem at the operating system level. You can read some of the discussion here: https://github.com/android-ndk/ndk/issues/447

Now the good news is Google fixed the issue (as indicated in the thread above). We tested it on previews and it seemed fine. Now Google has shipped Android Oreo 8.1, I got it for my Nexus 5X device this morning, installed it, and I can now debug a Delphi application as usual. I captured an image of the program stopped at a breakpoint below. 

Now this is not related to 10.2.2 in any way, as the change was only on the Android side, not the RAD Studio side. What we have fixed at our end is the display of the device name as target, but that wasn't a really big issue anyway.

Categories: News, Blogs, and Tips

New VCL Date and Time Picker Controls in Delphi 10.2.2

Marco Cantu - Wed, 12/13/2017 - 08:34

We at Embarcadero continue to consider the VCL as the best library for Windows-specific GUI development and are continuing the effort of improving and modernizing it, particularly improving the overall support for Windows 10. One of the directions of this effort (along side with styling, WinRT API, Desktop Bridge and more) is the addition of new VCL controls with the look of feel of the latest Windows platform controls, part of the WinRT UI layer. We have already delivered similar controls in 10 Seattle and 10.1 Berlin, and now adding 2 more in this release.

The goal od this control is to offer a more modern UI for VCL applications, adopting the Windows 10 UI style and elements without forcing you to rewrite the entire application (as someone in Redmond suggests) and allowing you to build programs that will still work fine and look great on Windows 7 -- a version of Windows still largely used today.

This is the reason why this family of controls is a set of pure VCL controls, that mimic the WinRT controls with no WinRT dependency. You can see the current list in the image below. Of these 4 controls are new in 10.2.2 Tokyo, the two pickers I'm covering in this blog post and two additional container panels I'll cover in a separate post.

As the name implies, the Date Picker and Time Picker components offers a simple, intuitive, and modern way to select a date or a time. These components are highly configurable, and can be adapted to any locale and format -- as these are quite different depending on where people live. 

TDatePicker

The date selection component both displays a date in a given format and offers the user a simple way to select a date value from a dropdown. Rather than displaying a calendar, the user can change the day, month, and year values separately, similarly to what happens in most mobile platforms and applications. The user can change the selection with the keyboard arrow keys, clicking with the mouse on the upper or lower elements of a list or on the top and bottom arrows, or using the mouse wheel.

The key property of the component is the DateFormat property. This allows you to establish the format in which you want to display the date, changing the sequence in which the control displays the elements (month/day/year vs. day/month/year, vs year/month/day, etc.). This affects both the initial display and the actual selection. Below you can see a couple of different configurations, one at design time above and one at runtime. You can also see in the drop down a list of sample configurations, including month names or numbers, one or two digit days, and so on. The image is from the DateTimePickers sample that ships with RAD Studio 10.2.2 in the VCL section of the demos.

More information about the component is available in the RAD Studio DocWiki at http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Using_the_Date_Picker_Control.

TTimePicker

The time selection component is very similar to the date selection. Again it has multiple sections for the hour, the minute, possibly the seconds, and possibly the AM/PM selector. In this case the fundamental property is the TimeFormat property. Again, it determines both the display and the pickers behavior. You can include seconds or exclude hours and add AMPM to the time format to use a 12 hours format and to include an AM / PM selector to the dropdown.

Again, here is an example with a couple of different settings (at design time and runtime) with an image taken from the same demo mentioned above.

Additional documentation is at http://docwiki.embarcadero.com/RADStudio/Tokyo/en/Using_the_Time_Picker_Control.

That's all for now. Stay tuned for info on the other two new VCL controls in 10.2.2, or join the intro webinar tomorrow.

Categories: News, Blogs, and Tips

Delphi 10.2.2 Has Been Released

Marco Cantu - Tue, 12/12/2017 - 12:56

As you can see at https://community.embarcadero.com/blogs/entry/rad-studio-10-2-2-released-today, the new version 10.2.2 of Delphi, C++Builder, and RAD Studio is now available. 

The new features are covered in the docWiki, at http://docwiki.embarcadero.com/RADStudio/Tokyo/en/10.2_Tokyo_-_Release_2

There are hundreds of bugs fixed (including over 150 bugs reported by customers in Quality Portal), as you can read in List of new features and customer reported issues fixed in RAD Studio 10.2 Tokyo Release 2 (we'll close the matching QP report in the coming days).

In the coming days I and the other PM will write a few blog posts on specific features added to the product. Also, there is a webinar on Thursday you can sign up for (at 3 times in the day). It will be an introduction to 10.2.2. Follow one of the 3 links at: https://community.embarcadero.com/index.php/all-events?language=en-GB&sort=embevent.

Categories: News, Blogs, and Tips

Delphi Blogs of the Month #57

Marco Cantu - Tue, 12/12/2017 - 01:51

As usual, this is a collection of links to relevant blog post and other newws you might heve missed over the recent perios of time, and that relate with Delphi one way or another.

Embarcadero News

There is a new Sencha MVP program, similar to the RAD Studio one: https://www.sencha.com/blog/sencha-mvp-program/

Healthcare App Prototype Built In Delphi Wins First Place In Startup Weekend Competition! Read more at https://community.embarcadero.com/blogs/entry/healthcare-app-prototype-built-in-delphi-wins-first-place-in-startup-weekend-competition

Blog Posts

Top 10 Most Popular Open Source Delphi Projects On GitHub By Star Rating by Eli at https://community.embarcadero.com/blogs/entry/top-10-most-popular-open-source-delphi-projects-on-github-by-star-rating

RAD Studio Custom Editor Sub-views by David Hoyle at http://www.davidghoyle.co.uk/WordPress/?p=1831 (this is an extremely detailed example of writing editor views, which is a fairly complex extension to the RAD Studio IDE)

Persisting enumeration and sets to JSON by Chee Wee Chua at http://chuacw.ath.cx/blogs/chuacw/archive/2017/12/11/persisting-enumeration-and-sets-to-json.aspx (a small and handy tip)

Microsoft has a very interesting blog post by Matteo Pagani covering the Desktop Bridge, a technology we support in Delphi, and while not everything is directly applicable, it is a very interesting read: https://blogs.msdn.microsoft.com/appconsult/2017/11/06/desktop-bridge-best-practices-and-common-issues/

Supporting iPhone X display with Delphi by Dave Nottage at http://delphiworlds.com/2017/11/supporting-iphone-x-display-with-delphi/ (some related improvements will be made available in RAD Studio 10.2.2)

Delphi + Enterprise Connectors + RAD Server = SAP native client for iOS and Android by Fernando Rizzato at https://community.embarcadero.com/blogs/entry/delphi-enterprise-connectors-rad-server-sap-native-client-for-ios-and-android (given the Enterprise Connectors cannot be used directly on mobile, you need a middle tier architecture to leverage them on your phone -- which also opens us to using push notifications)

Experimenting with Neural Networks – Part 6 by Craig Chapman at http://chapmanworld.com/2017/11/19/experimenting-with-neural-networks-part-6/ (read the previous 5 parts as well, of course)

Massive Collection Of Design Patterns, Frameworks, Components, And Language Features For Delphi at https://community.embarcadero.com/blogs/entry/massive-collection-of-design-patterns-frameworks-components-and-language-features-for-delphi

Older but Great Posts

I missed this, but worth highlighting: A Delphi Primer with RAD Studio 10.2 by T Theobald at http://borkedcode.com/wp/?p=1470 (a nice, long, and detailed "first look" to Delphi)

Roll your own lightweight, scalable backend using ZeroMQ at https://blog.grijjy.com/2017/05/02/roll-your-own-lightweight-scalable-backend-using-zeromq/

Projects and Libraries

Pyscripter is a feature-rich but lightweight Python IDE (written in Delphi): https://github.com/pyscripter/pyscripter. There is also a related Python Delphi integration package at https://github.com/pyscripter/python4delphi and this classic page http://www.atug.com/andypatterns/pythonDelphiTalk.htm

 

 

Categories: News, Blogs, and Tips

Cross JIRA Analysis with FireDAC CDATA JIRA Connector

Marco Cantu - Fri, 11/24/2017 - 08:06

In Embarcadero, for the RAD Studio project, we have two JIRA systems. One is a public system better known as Quality Portal (https://quality.embarcadero.com), while the second is an internal JIRA system accessible only behind the firewall. The two systems are kept in sync, as I explained in the past, so that a bug opened in the public system is reflected in the internal one; as we close a bug in the internal system and ship the fix, the internal status is reflected in the public system.

Almost always. In fact, there are reasons (timing, specific configurations, unexpected workflows, timeouts during synch operations, scripts that get stuck...) that prevent the regular flow to happen, leaving bugs in an inconsistent state. Specifically, we often have bugs closed internally that remain open (indefinitely) in the public system. I've spent time in the past looking for these orphaned items, but it is a fairly tedous process. So I though of writing an application to automate this. I could have used JIRA own scripting, but the process needs manual overview, which makes it more complex. So why not use Delphi?

Using the CData JIRA Enteprise Connector to run a query against JIRA and storing the data in a dataset takes literally a few minutes. You can use FireDAC query editor to refine your query, and write fairly standard Delphi dataset processing code. This blog post is a description of what I did to achieve my goal -- and the application I build it going to save me a lot of time in the future.

First, I've added to a data module (of a good old VCL application) the components needed to access quality portal and query for all of the open issues:

object QualityportalConnection: TFDConnection Params.Strings = ( 'URL=http://quality.embarcadero.com' 'ConnectionDef=QualityPortal' 'IncludeCustomFields=true') LoginPrompt = False end object QPIssuesTable: TFDQuery Connection = QualityportalConnection SQL.Strings = ( 'SELECT Key, StatusName, IssueTypeName, Summary, InternalID FROM ' + 'CData.JIRA.Issues where ProjectKey = '#39'RSP'#39' AND StatusName = '#39'Open'#39) end

The connection uses the IncludeCustomFields flag to retrieve extra custom fields of our JIRA installation, namely the cross reference from one JIRA system to the other, stored in the InternalID field -- and something a regular user without admin permissions should not be able to see. In fact, you need to provide your user name and password, the regular ones you use on the site.

For query I've picked the fields I'm interested in, to reduce network traffic (I'm reading a lot of data!) and filtered on RSP (Data Studio Project) and Open status. You can see the query running in FireDAC query editor below:

I also created static field objects for all fields in the query. For the internal JIRA analysis I've defined a query to retrieve information about an individual item, using a parametric query (like in SQL):

SELECT Key, StatusName, FixVersionsAggregate, StatusName, ResolutionName FROM CData.JIRA.Issues where Key = :key

With this query I'm retrieving the status, the type of resolution and the fix version. The basic approach of the application is to iterate all of the items open in the public system, fetch the internal status and check for inconsistencies. This is the basic loop:

QPIssuesTable.Open; // for each, check internal status QPIssuesTable.First; while not QPIssuesTable.EOF do begin JiraIssuesTable.Close; JiraIssuesTable.Params[0].AsString := QPIssuesTableInternalID.AsString; JiraIssuesTable.Open; // consider only issues closed internally if (JiraIssuesTableStatusName.AsString = 'Closed') then begin   ...     end;     QPIssuesTable.Next; end;

There is another part of the code I'm omitting to examine the fixVersion, which is a string with same complex JSON structure (an array of records). I need to extract the version number to see if the issue was closed in the past or it has just been closed for a not-yet-released version (in which case, it is fine). For all of the matches (issues closed in released versions) I add them to an FDMemTable created with appropriate fields and connected to a DBGrid:

      begin         FDMemTable1.Insert;         FDMemTable1QPKey.AsString := QPIssuesTableKey.AsString;         FDMemTable1JiraKey.AsString := JiraIssuesTableKey.AsString;         FDMemTable1QPStatus.AsString := QPIssuesTableStatusName.AsString;         FDMemTable1JIRAStatus.AsString := JiraIssuesTableStatusName.AsString;         FDMemTable1IssueType.AsString := QPIssuesTableIssueTypeName.AsString;         FDMemTable1Resolution.AsString := JiraIssuesTableResolutionName.AsString;         FDMemTable1Summary.AsString := QPIssuesTableSummary.AsString;         FDMemTable1FixVersions.AsString := fixJSONString;         FDMemTable1.Post;       end;

With this code, I obtain a grid with all items most likely out of synch, as displayed below, which lists the two IDs, the status on both systems, the internal resolution, and the version is was fixed:

The version number are internal ones, but I imagine you can guess which public version they match to. With the help of the data in this grid, I can go over the issues, open them in the internal system (if in doubt), and decide what to do. If I want to synchronize them, I need to add them to a list in the format expected by a JIRA script we use to force the synchronization. By double clicking on the grid, I execute the trivial code below that creates the comma separated list of keys I need:

procedure TForm14.DBGrid1DblClick(Sender: TObject); begin Edit1.Text := Edit1.Text + ', ' + DataModule15.FDMemTable1JiraKey.AsString; end;

So much less copy and paste! And now I can use the next couple of days to cleanup the Quality Portal system a bit...

Categories: News, Blogs, and Tips

New on Embarcadero Academy: CodeRage Replays and my New Course and Bundle

Marco Cantu - Mon, 11/20/2017 - 08:10

Embarcadero Academy is an independent online training site available at https://www.embarcaderoacademy.com/. The site has an overall agreement with Embarcadero as a key destination for online training for the company development tools products.

The academy site co-hosted the CodeRage XII conference the other week and it is not offering the complete set of replays. All you need to do is create an account on the platform and sign up for the free CodeRage course at https://www.embarcaderoacademy.com/p/coderage-xii.

On my part, I added a new course on Anonymous Methods and a course bundle on Modern Delphi Language including the courses on interfaces, generics, and anonymous methods. This bundle includes 6 hours of content. Also, all of the courses have a 20% special CodeRage discount until the end of November.

There are many other great classes on Delphi by Alister and non-Delphi classes as well. It is also now possible to take the Delphi certification exams on the academy site. There are other ideas floating around to improve the academy, like live online classes and subscriptions: more than willing to get your feedback (that I can share with the academy site team) or suggestions to me for other topics to cover in future additional courses.

Categories: News, Blogs, and Tips

Explaining Tasks in Delphi Parallel Library... by Creating too Many Tasks

Marco Cantu - Thu, 11/16/2017 - 09:19

Recently, I wrote some new demo for Delphi PPL (Parallel Programming Library), while doing some research for an online class -- which is available since last week on the Embarcadero Academy site ("Anonymous Methods in Delphi"), along with a new overall bundle of my classes ("Master Modern Delphi Language Techniques").

In the past I've used different ways to explain tasks and compare them to threads. Tasks are lightweight and managed more efficiently, than threads. The PPL creates a thread pool and assigns pending tasks (and their code) to a pool of threads that depends on your CPU cores and current workload. But these descriptions might still explain tasks and threads as fairly similar in scope. Now let's look at this source code snippet:

procedure TForm12.btn100sClick(Sender: TObject); var tasks: array of ITask; Value: Integer; I: Integer; begin SetLength(tasks, 100000); Value := 0; for I := Low (tasks) to High (tasks) do begin tasks[I] := TTask.Create (procedure () begin TInterlocked.Increment (Value); end); tasks[I].Start; end; TTask.WaitForAll (tasks); Memo1.Lines.Add(Value.ToString); end;

As you can see this event handler creates not hundred, but hundred thousand tasks. Each of them has an extremely simple operation to complete -- fairly nonsensical, I know. But you can create 100,000 tasks and they'll all done done in less than a second, on my computer. Consider creating 100,000 threads! that would create a significant extra overhead. By running this code, the tasks are assigned to a few threads in a pool, as you can see in the debugger:

Small demo and pretty much useless code, but I think it does a good job in highlighting the lightweight and flexible nature of nature of tasks, when compared to threads.

Categories: News, Blogs, and Tips

CodeRage XII Starts Today (With European Schedule)

Marco Cantu - Tue, 11/07/2017 - 02:34

The online CodeRage conference by Embarcadero starts today: https://community.embarcadero.com/article/16578-coderage. Registration is still oepn at https://register.gotowebinar.com/register/7990350396754529539.

With dozens of session based on central US time zones, it is easy to get confised. So I've amended the official calendar for those based in Europe (warning, in case of last minute schedule changes, I won't probably be able to udpate it). Here are thre three PDFs for the 3 days with UTC+1 or Central Europe Time zone times:

Tuesday Nov 7thhttp://blog.marcocantu.com/images/forblog/CodeRageXIIScheduleEuropeTueNov7.pdf

Wednesday Nov 8thhttp://blog.marcocantu.com/images/forblog/CodeRageXIIScheduleEuropeWedNov8.pdf

Thursday Nov. 9thhttp://blog.marcocantu.com/images/forblog/CodeRageXIIScheduleEuropeThuNov9.pdf

Remember you can sign-up and follow the event also on the Embarcadero Academy site at https://www.embarcaderoacademy.com/

I'll be "live tweeting" any even vaguely Delphi-related CodeRage information https://twitter.com/delphitweetday. Follow the account if you don't do already!

Categories: News, Blogs, and Tips