Firebird News: CopyCat replication engine v. 3.04.0
Delphi Code Monkey: Hey Marco, Here's how to fix Delphi: Make it fast.
I get paid to write Windows applications, and Delphi is still the best tool for that job. But it needs some improvements. Here are the improvements that I believe would benefit everybody using Delphi. Delphi's speed issues slowed me down today, and that's not acceptable. I work with large applications in Delphi, some of which approach 1.5 million lines of code. Delphi just doesn't handle them well.
1. Ditch the Microsoft Document Explorer. Even Microsoft has ditched it.
2. Give me F1 context sensitive help that is faster than Googling or searching Stack Overflow.
3. Get rid of the 3-5 second delay popping down the Edit menu when you have a large project open.
4. Fix the useless Error-Insight compiler. Get rid of all the various parsers in your product and replace them all with one new one that can do all the parsing you need done. The differences in the parser's support for various Delphi language features added between Delphi 7 and XE4 has resulted in the broken mess of code-insight, error-insight, and code-completion, not to mention code-formatting glitches.
5. Learn from all the Java and C++ IDEs out there about using a background process to do do scans of the edit buffer so that it does not freeze up the editor, ever. It's never okay to block the user from inputting text while you have a big fat think. Never. Fix anything that freezes the editor long enough to cause users to lose data because the IDE is frozen while they were typing code. This slowed me down and caused me to lose a good chunk of my productive working time today.
6. Some of my forms and data modules take 8 to 10 seconds to open and become editable on a Xeon computer with 8 cores. This is just not cool. What kind of stupid algorithms are you doing at DFM load time that could take 10 seconds to parse a DFM? I could compile 100 megabytes of Delphi code in that time from the command-line compiler.
7. Make one checkbox in the preferences that says "Make it fast". Turn off all the slow stuff with that one checkbox, so that when what I need is an editor that has Delphi syntax highlighting, and a compiler and error list, it gets that right, and forgets everything else.
As cool as the Mac stuff is, and I will blog about how cool it is soon, what I want is a fast Delphi.
The road to Delphi: Added support for RAD Studio XE4 in the Delphi IDE Theme Editor.
This entry is just for announce which the Delphi IDE Theme Editor now supports RAD Studio XE4.
Installer of the Delphi IDE Theme Editor
DelphiTools.info: What would get you to buy a newer Delphi version?
This is a practical poll question, what would get you to buy a newer Delphi version?
What would you like to see most and foremost, and would most have a use for?
To force you to choose, you can only pick two items!
Behind the connection: Enabling floating form designer in Delphi XE4
PARMAJA: MiniLib on Git
MiniLib, http://sourceforge.net/projects/minilib/
Git now is the version control, instead of SubVersion, for 2 of reasons.
1 – I like to work offline, commenting and show log, while I can’t have a permanent internet connection.
2 – Branching merging, it merge the full history from where to everywhere.
But I still like the version numbers in SVN it is more useful and it is easy human trace the changes.
jed-software.com: XE4 Mobile Tip #2 Loading local HTML content
I’ve already answered this on the newsgroups however it deserves a little more attention.
The most important thing to do when deploying additional files with your app is to make sure they are prefixed with “StartUp/”. This tells the deployment manager to deploy these files with the application and place them in the folder specified after the StartUp/ prefix. This prefix is case sensitive.
Here is a screen capture of the deployment manager for the sample project available for download at the end of this post.
Verify file is included without running the app
You can even verify that the files have been deployed with the app by looking in the Applications section of your device in the XCode Organizer.
Sample code
The code below loads the content of the file into the WebBrowser control that is on the form.
unit Unit288; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.WebBrowser, FMX.StdCtrls, FMX.Layouts; type TForm288 = class(TForm) LoadHtmlButton: TButton; WebBrowser1: TWebBrowser; Layout1: TLayout; procedure LoadHtmlButtonClick(Sender: TObject); end; var Form288: TForm288; implementation uses IOUtils; {$R *.fmx} procedure TForm288.LoadHtmlButtonClick(Sender: TObject); var LFilename: string; begin LFilename := TPath.GetDocumentsPath + '/index.html'; if TFile.Exists(LFilename) then WebBrowser1.Navigate('file://' + LFilename) else MessageDlg(Format('File not found: %s', [LFilename]), TMsgDlgType.mtError, [TMsgDlgBtn.mbClose], 0); end; end.
Works on my device!
Download the Code
Download the sample project.
A couple of notes
- You wouldn’t deploy a static file to the Documents folder unless you wanted it to be backed up (via iTunes or iCloud) with other user data.
- The best location for static files is Library/Application Support/, this is content that is generated when the application runs, or is included with the application.
jed-software.com: XE4 Mobile Tip #1 Disable the GPU Canvas
If you don’t like circles with jagged edges, you can disable the GPU canvas.
Using the GPU Canvas:
Not using the GPU Canvas:
Full image comparison at 200% using Beyond Compare. Click to enlarge to full size (2600 x 1540).
NOTE: If you see other drawing issues, enable the GPU canvas again just to see if it is a canvas issue.
Disabling the GPU Canvas
To disable the GPU canvas you must modify the project file source.
Add FMX.Platform and FMX.Consts to the uses clause. I suggest adding these items after the FMX.Forms entry but before any other units. You MUST leave System.StartUpCopy as the first unit in the uses clause.
Before Application.Initialize is called, enter this line:
TPlatformServices.Current.GlobalFlags.Add(GlobalDisableiOSGPUCanvas, True);
Delphi Haven: FMX anti-pattern: returning nil rather than raising an exception on an invalid state or arguments
In the Delphi RTL and VCL, a method called LoadFromFile or the like will raise an exception if the file doesn’t exist or is invalid. Similarly, if an object property getter implements a lazy-loading pattern (meaning, the value of the property will only be initialised when first needed), it will raise an exception if the situation is such that nothing valid can be loaded or initialised. This is pretty basic exception programming – when an error arises, the flow of the calling code is forcibly interupted with a clear account of what call was invalid. Imagine if (say) TBitmap.LoadFromFile didn’t raise an exception when the file name passed to it didn’t refer to a valid bitmap file – calling code could go happily on its way assuming a graphic has been loaded when it hasn’t. Likewise, what if the Items property getter for TList<T> just returned nil (or equivalent) with an out of bounds index? If T is a class type, then off-by-one errors in the calling code will end up with cryptic access violations later on that might be nowhere near where the erroneous call was actually made!
Alas, but such basic understanding of exception programming is not grasped by at least one developer on the FMX team. Repeatedly across the XE2, XE3 and now (I learn) XE4 releases, methods that an experienced Delphi programmer would expect to raise an exception when nothing valid can be returned do not. As soon as one case is fixed – e.g., the TFmxObject.Children property getter was done so in XE3, albeit implicitly – another one or two are added, and frankly, it needs to stop now. The latest cases I learn are the HScrollBar and VScrollBar property getters on TScrollBox – done properly in XE3, the anti-pattern has however been introduced in XE4, causing ‘random’ access violations in TMemo (the FMX TMemo inherits from TScrollBox).
twm’s blog: experimental GExperts + code formatter for Delphi XE4
There isn’t yet any official release of GExperts for Delphi XE4 but if you don’t mind a little bit of manual work for installing, you can have it anyway.
WARNING: I have just now made this version compile with Delphi XE4. I have not done any tests. You are on your own and responsible for any damage this version might do to your computer and your files. If you don’t accept this responsibility, do not download the software!
Download
GExperts-XE4-1.37-experimental-twm-2013-04-28.zip
and unpack it to a folder of your choice
(e.g. c:\program files\GExperts for RAD Studio XE4)
Copy the expert you want to use from one of the subdirectories created:
- EditorExpert
- RegularExpert
to the main directory.
Use the ExpertManager tool to register GExperts to Delphi XE4.
Voila, you are done.
This version is based on the current source code from the GExperts svn repository. I have not released it for any other Delphi versions because nothing has changed since the last release.
The Wiert Corner - irregular stream of stuff: jpluimers
Thomas Mueller is fast: experimental GExperts + code formatter for Delphi XE4 « twm’s blog.
–jeroen
Filed under: Delphi, Delphi XE4, Development, Software Development
Behind the connection: Delphi XE4 and AnsiString
Daniel Magin's Logfile: Using InterBase Lite and InterBase ToGo in Delphi iOS Applications Step by Step Guide
Using InterBase Lite and InterBase ToGo in Delphi iOS Applications - Step by Step Guide
With RAD Studio XE4 a new InterBase edition has been rolled out. The existing InterBase edition family (Server, Desktop, Developer and ToGo) has been enhanced by an edition called “IBLite”. This edition may be deployed for free with your applications. IBLite uses the embedded deployment model similar to the InterBase “ToGo” edition, some limitations apply though. Following is an overview of InterBase editions and their features and limitations:
(click on Images to enlarge)
The most important IBLite limitations are:
- Max. 100MB database size
- Max. 1 simultaneous transaction
If you need more space or transactions, then your other (paid though) option for iOS devices is the “ToGo” Edition. On mobile devices 100 MB with one transaction is very likely to be sufficient though.
Developing and Deploying InterBase Applications for iOS Devices
All following steps are identical for IBLite and InterBase ToGo.
License Keys
RadStudio XE4 comes with a free IBLite serial key and an InterBase ToGo serial key for test deployments. The ToGo serial key may only be used for testing deployments and is not meant to be published with apps to the App Store. To go into production with InterBase ToGo you need a separate InterBase ToGo deployment license. Please contact you local Embarcadero office for pricing and terms. The IBLite key that comes with XE4 is good to be used in production environment - it is completely free!
The keys look like this:
IBLite XE3 for iOS Deployment License
AAAA-BBBBBB-CCCCCC-DDDD
InterBase XE3 ToGo Test Deployment
AAAA-BBBBBB-CCCCCC-DDDD
The InterBase version that comes with RAD Studio XE4 / Delphi XE is „XE3“ - so don‘t get confused on the version numbers.
You need to register the keys and create a REG______.txt file, which will be deployed onto the device together with your app.
The registration process is a little tricky and hopefully Embarcadero will make that more convenient in the future. If anyone knows shortcuts to this process, then drop me a note, so that I can update this documentation.
After installing InterBase XE3 Developer Edition (which is usually done by the installation process of RAD Studio XE4) you need to launch the Embarcadero License Manager. The License Manager can be found in the InterBase bin directory.
These are the default location of the InterBase bin directory:
Windows 64bit
C:\Program Files (x86)\Embarcadero\RAD Studio\11.0\InterBaseXE3\bin\ LicenseManager.exe
Windows 32bit
C:\Program Files\Embarcadero\RAD Studio\11.0\InterBaseXE3\bin\ LicenseManager.exe
In the LicenseManager select Serial - Add from the Menu:
In the „Add Serial Number“ Dialog type in your IBLite or InterBase ToGo key and Press OK.
Now your key should show up in the Treeview under „Unregistered serial numbers“
License Registration
All license keys need to be registered with Embarcadero, to do so, open the context menu for the key you just entered and click „Register“
The Embarcadero Product Registration Dialog will pop up. That is the same dialog you have seen after you installed RAD Studio /Delphi itself:
The next Step is VERY IMPORTANT and different from the RAD Studio / Delphi registration process:
The online registration process does not work using this dialog, unfortunately. So, in other words: DO NOT REGISTER ONLINE with this dialog!
Did I mention this already?
DO NOT REGISTER ONLINE with this dialog!
Once again:
DO NOT REGISTER ONLINE with this dialog!
Remember:
DO NOT REGISTER ONLINE with this dialog!
Instead, open your Web browser and go to https://reg.codegear.com
Yes, use the CodeGear domain name as the SSL certificate is still under CodeGear‘s name and not under Embarcadero‘s. (Embarcadero Web master - I am looking at you SSL certificates are not that expensive any more. Certificate errors on embarcadero.com are ☺).
Enter your Serial Number and Registration Code from the LicenseManager into the Web form:
Press „Next“ in the Web form. The next step requires you to login with your Embarcadero EDN Account credentials.
After pressing „Next“ again, you should get the following „Product Registration“ Web form:
At the very bottom of that Web form you will find options to download or send per email an activation file for InterBase.
This activation file comes as REG___.txt, which you need to add to your iOS App, to get InterBase unlocked.
First, rename REG____.txt, depending on the edition you have chosen:
- reg_iblite.txt (IBLite)
- reg_ibtogo.txt (InterBase ToGo)
Copy the registration file(s) to:
C:\Users\Public\Documents\InterBase\redist\InterBaseXE3
Now you are ready to to develop your first iOS Application with RAD Studio/Delphi XE4 and InterBase
Sample Application
Create an new FireMonkey Mobile Application
Add a TButton and a TListbox to your blank main form.
Now add a new connection to the employee sample database. To do so open the Data Explorer Window in Delphi and select „Add New Connection“ under the IBLite/ToGo tree item and name the connection „Employee“.
In the Connection Configuration dialog add the path to Employee.gdb. This file can usually be found in Delphi‘s Sample folder, under „Data“. Default user name is „sysdba“, default password is „masterkey“ (without quotes). See the screenshot for details:
Double click / open the new „employee“ tree node to see all tables, that come with Employee.gdb.
Now drag and drop „employee“ from the tree onto your main form. This will automatically create a correctly configured TSQLConnection component on your form:
Remarks: In my sample I am storing Employee.gdb on the iOS device under
/Documents/data/employee.gdb. Of course you can use any directory which is available to your app on the device. Using the Documents folder has the advantage that everything in here will be included in the iOS Device backup process. This is true for local backups with iTunes or iCloud backups. The /tmp/ folder in contrast would not be backed up.
To connect to the database at runtime (on the iOS device that is), an IFDEF IOS is used in the „BeforeConnect“ event of the TSQLConnection to set the path to the database file.
In the „ButtonClick“ event add the following code:
Before running the App on the iOS simulator or iOS device we have to add some items to the Deployment Manager in which can be opened via menu item „Project - Deployment“
The Deployment Manager lists all files that get bundled and deployed with your App on the device. Important to note is that all items have a local path (on your development machine) and a remote path on the iOS device:
You need to add InterBase client files and the license file that you created earlier.
Remarks: Select „All Configurations“ in the Deployment Manager. Otherwise you will have to perform these steps for Simulator, Device and Debug/Release configurations separately.
First add some items from the „Featured Files“ dialog:
For IBLite use „InterBase ToGo“ too, as the different behavior between IBLite and InterBase ToGo is controlled by the license file.
After adding these items you will find them in the Deployment Manager‘s items list. You will also see two license files: reg_iblite.txt and reg_ibtogo.txt. Make sure that only ONE of them gets deployed, i.e. disable or remove either of them.
Now add the EMPLOYEE.GDB File to Deployment Manger:
After adding the file you need to change its remote path for the simulator and the device! To do so, double click the „Remote Path“ cell. Enter: „StartUp\Documents\data\“
Now save all files and run your first InterBase App on the iOS Device.
Good luck and have fun
Daniel Magin , Olaf Monien, Daniel Wolf
info ( a t ) Developer-Experts.net
Embarcadero MVP
Te Waka o Pascal: Adding Insult to Injury
DelphiTools.info: Gaining Visual Basic OLE super-powers
Visual Basic in its various incarnations and off-springs has super-powers when it comes to OLE Automation, aka late-bound COM through IDispatch.
Super Powers?
For instance, when doing MS Word OLE automation, you can in VBS and VBA write things like
WordApp.Documents[1].Name
which in Delphi (and many others) has to be written as
WordApp.Documents.Item(1).Name
and it can also call some methods like
set v1 = WordApp.CentimetersToPoints(2.5) set v2 = WordApp.InchesToPoints(2.5)
which Delphi, FreePascal, PowerBasic, Python, C++’s CComPtr and others are unable to call, and which instead result in an “unspecified error” without further description.
While trying to solve the above riddle, I found posts about it for various languages and frameworks, dating back to the beginning of the millennium with no solutions, just specific workarounds.
Until today that is, bit thanks to David Heffernan and Hans Passant, two StackOverflow super-stars.
The reason is that some “methods” like CentimetersToPoints aren’t methods, they’re really indexed properties that you can’t call as indexed properties (ie. WordApp.CentimetersToPoints[2.5] will fail in Delphi as well).
The Magic Potion
If you want to get the same super-power, the fix is basically to not follow the spec when calling IDispatch.Invoke, and instead of using DISPATCH_METHOD, use DISPATCH_METHOD or DISPATCH_PROPERTYGET.
In Delphi’s ComObj, DispatchInvoke function that means the
end else if (InvKind = DISPATCH_METHOD) and (ArgCount = 0) and (Result <> nil) then InvKind := DISPATCH_METHOD or DISPATCH_PROPERTYGET;
should be changed to just
end else if (InvKind = DISPATCH_METHOD) then InvKind := DISPATCH_METHOD or DISPATCH_PROPERTYGET;
And the call will now go through. So all the previously mentioned languages and environment that follow the spec are doomed to fail.
Similarly, investigations have showed that for some OLE automation properties “get” to pass, you need to use DISPATCH_METHOD or DISPATCH_PROPERTYGET, and using just DISPATCH_PROPERTYGET will fail.
Speculations
There is a suspicious bit in the MSDN documentation for Getting and Setting properties:
Properties are accessed in the same way as methods, except you specify DISPATCH_PROPERTYGET or DISPATCH_PROPERTYPUT instead of DISPATCH_METHOD. Some languages cannot distinguish between retrieving a property and calling a method. In this case, you should set the flags DISPATCH_PROPERTYGET or DISPATCH_METHOD.
Do you know a language that can’t distinguish between properties and methods? Visual Basic.
Given that Visual Basic was a primary user of OLE Automation, it’s likely using DISPATCH_PROPERTYGET or DISPATCH_METHOD all the time indiscriminately, so I’ll speculate that at some point, using both dispatch flags became the effective spec. I suppose Raymond Chen might be able to provide some further insight?
Bottom Line
DWScript COM Connector now has the same OLE Automation super-powers, and it’ll work without modifying the ComObj unit.
The COM connector uses its own IDispatch.Invoke wrapper, distinct from Delphi, which is incidentally also capable of working with Single precision floats (requires a workaround in Delphi).