Adam’s Sept 2020 Meeting Summary
Agenda
- Integrating DevExpress Word Processing and Spreadsheets into Delphi – Tim Hayes
- Designing a dashboard in Delphi, SQL, HTML, JS – David Mew
- Nugget: The Delphi Parser- Jason Chapman
Adam’s Summary
NEWS AND UPDATES
After a holiday month in August, the group reconvened for another on-line meeting on 16th Sept, welcoming several new members.
The DevGroup Slack is becoming active, which feels great. Each meeting has an active channel, and #newsandinterest, #talks-planning & a couple of others are active too. It is becoming more normal to post useful links and comments in the Slack during the meeting, making it easier to return to issues that were raised. If you haven’t yet, join the DevGroup Slack, the 20200916meet channel includes at least a dozen really useful links.
Please go to #talks-planning and offer sessions we might enjoy, and vote for sessions you would like to see and add talks you are willing to do (but only one per message or the Slack Police will come for you).
Bold now open source
In the mid 2000s Bold was an important initiative in the Delphi-world. UML modelling of objects which could be used to directly generate Delphi classes. Bold also spawned the valuable ModelMaker Code Explorer (MMX) which many of us use as an IDE plug-in. Members discussed the fact that EMB seem to have picked up Bold (?) or made it open source or … what exactly?
Issues with 10.4.1
A good proportion of members are working with Delphi/RAD Studio 10.4. A few are moving on to 10.4.1. Upgraders reported issues (also reported elsewhere) with LSP & Code Completion. I for one will be sticking with 10.4 for a while, as it is a reasonably solid workable environment for me.
Martin Hamilton showed the SPF Text Editor, a truly old-school text editing tool.
SESSIONS
David Mew: HTML-based charts in a VCL app + web portal, using ApexCharts.js
David works for Savoy Systems, who have a mixed product-range serving cinemas with both Delphi desktop apps and on-line booking systems which work in the browser. Savoy are migrating from desktop to a more flexible desktop / web mode of development.
To help with this they are using the TChromium Delphi component which provides UI browser/HTML display capability in Delphi, with JavaScript capability. This allows them to build Delphi apps which behave like web-apps.
In the session David showed how to build an app which used the open source ApexChart javascript charting library (https://apexcharts.com/).
David showed Savoy’s components, which start with a base component that has a SQL string property, setting this triggers a fetch from the database and chart generation, each component outputs HTML formatted to represent 1 chart.
Descendent classes can then be written to generate different type of chart. The application loads the ApexCharts library, which is held as the XML Property of a TdbWebSession, and the HTML of individual charts references this property, pulling in the behaviour of the library.
David showed a ChartGroup component, which can pass parameters such as date-ranges to the Charts it owns, and the resulting (very attractive) dashboards his systems then generate.
There are large numbers of powerful Javascript libraries, and it was great to see a clear demonstration of how to harness these and pull them into the Delphi World. Members discussed the difficulty of picking the “right” library, as there are so many. Other members discussed alternatives to ApexCharts such as HighCharts, which is similar, but may not be open source.
Tim Hays: Developer Express Word Processor and Spreadsheet Components
Tim showed the amazing DevExpress components (https://www.devexpress.com/), which really do what it says on the tin: They provide quite fully featured versions of Word Processing and Spreadsheet programs in a Delphi context where the programmer has full control.
Members were a bit confused about the need for these components asking “why not just open a file in the users’ word processor?” But then Tim showed how his application allows users to make complex document management/merger and processing in a multi-document/multi-user context which requires full programmatic control of all the users’ actions, which would be virtually impossible without using the DevEx components.
DevEx are great. The VCL component-set now costs $1499, with an annual license that is also pretty high, so you need to be doing serious work with them. The components have a vast number of great features and clever architecture built into the Delphi IDE. Tim demoed dropping a DevEx Ribbon component onto a form and automatically linking it to the Word Processor component. This resulted in automated creation of Image-Lists, Action-Lists & all Ribbon buttons/actions etc., which would have taken a long time to program manually.
Tim then showed how to integrate an app with GoogleVision and how incredibly easy it was. This allows OCR of images (for example scanned documents) via a clear web-API. It is an incredibly powerful system, and relatively easy to implement using Google’s standard processes. It is a paid for service.
Jason Chapman: The Delphi Parser or The Delphi 7 Windows XP to Delphi Sydney Windows 10 Migration story part 1
All of us have been living the dream of Jason actually migrating his Line of Business Banking / Pensions application from Delphi 7 since he started talking about it 10 years ago. In this session we were treated to the story of part 1 of the actual conversion.
The project includes about 350,000 lines of code, so it is a decent-sized monster, and heavily RAD-oriented, with lots of frames and datamodules. It uses the BDE (of course it does) and a number of other deprecated technologies, including FIBPlus.
It was great to hear the real, gnarly story of Jason’s work so far, and to get pointers on how to go about such a massive and painful migration process. Just to make the story more fun he has started on three separate methods for the migration and was able to update us on all three. How he thought he could fit it all into a 30 minute session I will never know, he over-ran by 20 mins and still barely touched on many aspects of what he has done … part 2 is essential, and we will all be eager to hear the sagas continuation.
Migration method 1: Add Mock-classes to replace deprecated code.
- Attempt to compile.
- Where declarations are found which do not compile (ie “FBDatabase: TFIBDatabase;”) write pas files containing mock-classes to stand in for the non-existent class. (TFIBDatabase in this case)
- Populate these classes with methods and fields which match-by-name-and-type the methods in code.
- The classes don’t need to WORK, they just need to read correctly so the programme will compile.
- Once you have the mock-classes in place so the project compiles, you can then use these mocks as the basis for full classes which reference the new components you want to use to replace the old ones.
As Jason was not able (at the start) to access several of the component-sets used in the application for Delphi Sydney he could not even open forms in the IDE. As a work around he opened the pas files in VSCode, and used a command-line compiler to locate problematic declarations.
This method is powerful (as the mocks created are a valuable abstraction layer) but scary and difficult. I think most members thought this might ultimately be the best way to go forwards.
Migration Method 2: Using Refind, the Embarcadero tool, which comes free with new versions of Delphi.
Surprise surprise this tool isn’t actually very good. It is limited and doesn’t do much, perhaps it is helpful if you have a small project. Jason discarded it pretty quickly: A useful learning for the rest of us.
Migration method 3: Using The Delphi Parser (https://delphiparser.com/) This powerful paid-for component uses conversion scripts to convert your pas into new code.
The conversion script includes segments such as:
REPLACE: TQuery, OldPropertyName, NewProperty;
The engine will run through code, on a multi-pass basis as many conversions have to be done sequentially and code needs to be tokenized. In the above example, the Parser would find declarations of TQuery, and swap out the property in variables declared with that type. Note that this might be done AFTER TAnyQuery had been swapped for TQuery … complex layers, and the parser has to identify not just TQuery, but all the variables of type TQuery.
Jason has got it to work (after some back and forth with their support) the issue is that while it will get the project to compile, it doesn’t do much more, and still leaves multiple issues to fix (for example where there is no property on the replacement component to replace the property on the old component)
Which of the migration choices is the right one?
Which will work best?
How much of Jason’s time will all this absorb?
Tune in the future UK DevGroup meetings to find out …
The meeting then broke up for beer and general chit-chat.