Archive for the ‘Delphi XE2’ Category
Posted by jpluimers on 2012/04/26
Some very interesting tips from game development that apply juts as well to general software development.
On code health:
Now I always try to dig right down to the root cause of a bug, even if a simple, and seemingly safe, patch is available. I want my code to be healthy. If you go to the doctor and tell him “it hurts when I do this,” then you expect him to find out why it hurts, and to fix that.
Though tools like SourceMonitor can help you track your code health, the best tool is between your ears.
–jeroen
via: Dodgy Coder: Coding tricks of game developers.
Posted in .NET, Batch-Files, C#, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Delphi, Delphi x64, Delphi XE2, Development, JavaScript/ECMAScript, PHP, PowerShell, Scripting, Software Development | 1 Comment »
Posted by jpluimers on 2012/04/10
Lot’s of corporate environments keep killing the productivity of their software developers by running WorkPace. They claim to prevent RSI, but the main thing they do is getting you out of your mental flow.
Workpace (yes, it is written in Delphi) hooks itself into processes by injecting REC300.DLL into it.
That particular DLL prevents Delphi XE2 from installing in several of the systems colleagues tried, and gives you error messages like these:
'' is not a valid integer value
Followed by a bunch of access violations, and Process Monitor indicating issues reading the key HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\REC300.DLL which is part of WorkPace 3.0 (an old 2007 version).
The next problem was Digital Guardian (an old 2010 version) hooking itself into all processes. Uninstalling that is a pain, as it requires a special uninstall key, but luckily the automated update script on the SCCM server’s distribution share contained that in an encrypted form. Uninstalling this solved the problem.
Maybe newer versions of WorkPace and Digital Guardian wouldn’t have interfered with the Delphi XE2 install. If so, that would be another example of technical debt.
WorkPace and Digitual Guardian are most likely there because of government induced regulations in the corporate environment.
I’m feeling a bit like Dilbert now: the corporate environment is interesting, but often they make “getting work done” so much harder than it could be.
–jeroen
Posted in Delphi, Delphi XE2, Development, Opinions, Software Development, Technical Debt | Leave a Comment »
Posted by jpluimers on 2012/02/16
If you haven’t seen Jason announce this in the general Delphi 3rd party newsgroup or his announcement thread on the FaceBook Delphi Developer group yet, this is a definitive must read:
Jason Southwell (from arcana) just published DuckDuckDelphi: a unit to do Duck typing in Delphi XE2 (not XE):
Duck Duck Delphi
DuckDuckDelphi is an Open Source (MIT License) unit for Delphi XE2 which adds duck typing functionality to a normally strongly typed language.
Great stuff that makes a truckload of my code so much easier to maintain.
–jeroen
via arcana – DuckDuckDelphi.
(Edit: 1400 UTC+1 Sorry, wrong boolean; wrote “and” but should be “not” XE).
Posted in Delphi, Delphi XE2, Development, Software Development | 8 Comments »
Posted by jpluimers on 2011/12/22
Before installing updates, it is always wise to read the release notes.
In this case, the below quote from the Release Notes for XE2 Update 3 was very important for me, as I use the IDE Fix Pack:
IDE Fix Pack Is Not Compatible with Update 3
The IDE Fix Pack for XE2 is incompatible with XE2 Update 3. If you have the IDE Fix Pack for XE2, you should uninstall the IDE Fix Pack for XE2 before installing Update 3. A revised version of the IDE Fix Pack for XE2 will be made available at http://andy.jgknet.de/fixpack/ .
The cool thing is, on the same day that Delphi XE2 Update 3 got released, Andy also released the new FixPack 4.6 last week and also explained the cause of the incompatibility.
Note that because of the same reason, more products will need to be updated. EurekaLog also released an update, and I expect more vendors to release updates soon.
Update 3 breaks the monthly release cycle, but for a reason. This update contains way more fixes than the previous ones, in a much wider area and with short turnarounds between reporting and fixing (yes, it does pay to [WayBack] report bugs through QualityCentral). Just [WayBack] read the list of fixes. It is similar to the big updates we used to have for previous Delphi versions.
It also requires a lot more disk space, so make sure you have at least 5 gigabytes of free disk space.
Not related to Update 3, but still nice is that Thomas Müller made available for download the Expertimental GExperts version 1.35-2011-12-18 that is compatible with Delphi XE2. It includes a code formatter that has different bugs than the Delphi XE2 one, but for me usually works better.
–jeroen
via: Release Notes for XE2 Update 3 – RAD Studio XE2.
Posted in Delphi, Delphi x64, Delphi XE2, Development, QC, Software Development | 1 Comment »
Posted by jpluimers on 2011/12/20
When developing applications for iOS using Delphi XE2, it uses a smart but convoluted FPC detour.
That results in a few things you should take into account when developing iOS applications:
- Do not use Unit scope identifiers (that’s why for instance the FireMonkey unit FMX.Dialogs is called FMX_Dialogs when building an iOS application)
So don’t do a “uses System.SysUtils”, but “uses SysUtils” and don’t name your units using Unit scope identifiers for now.
It would be so nice if Embarcadero shipped the tool that made all the FMX_* units out of the FMX.* units; that alone would make code sharing between non-iOS and iOS applications in Delphi a lot easier.
- Do not use Generics (though FPC supports them, the FPC mode that Delphi XE2 uses for iOS compatibility does not)
- Do not use new style RTTI or TValue (they are not supported by FPC)
- Do not use any other dataset than the ones directly descending from TDataSet (so anything TClientDataSet or IBX like is out) mostly because those depend on external C obj files, Unit scope identifiers or new style RTTI
- Do not spread your application sources over multiple directories
- Do not use the TMyDynamicArray.Create shortcut of initializing dynamic arrays, but use a wrapper function that uses Open Array parameters as Rob Kennedy explains on StackOverflow.
- Do not run dpr2xcode after you have changed any files it generated (believe me, you will change those). This basically makes you have to reinvent most of the dpr2xcode logic, which is a real pain, as I’m still in that process and not completed.
These are the things you usually want to manually keep track of:
– most of the manual changes are keeping the “YourProject.dpr” and dpr2xcode generated “YourProject.pas” in sync
– altering the PNG files to show different splash graphics / application icons
I will extend this list over time.
Note that this detour should be gone in a future Delphi version, but for now you need to take the above into account.
It means that you might feel like programming with one hand behind your back. Well, the Objective C and Xcode way feels very similar, but from a different perspective :)
–jeroen
Posted in Delphi, Delphi XE2, Development, Software Development, xCode/Mac/iPad/iPhone/iOS/cocoa | 2 Comments »
Posted by jpluimers on 2011/11/02
Yesterday, Update 2 for Delphi XE2 / C++ Builder XE2 / RAD Studio XE2 became available for download.
A few notes from my experience upgrading from a full RAD Studio XE2 Update 1 install (from ISO):
- You need at least 5 Gb free disk space to install Update 2.
The installer won’t warn you in advance: it will indicate it needs more disk space when it cannot update the first file that does not fit.
In my case (VMware image of 40 Gb with 4 Gb free), that was not enough.
- It will leave a 300 Mb directory at %temp%\radstudio_xe2_update2_download
- Downloads are available from the altd http and ftpd ftp servers for registrered users at about 300 kilobyte per second each.
Expect a total download time of at least:
- 15 minutes for the 300 Mb XE2 Update 2,
- 90 minutes for the complete 2.5 Gb XE2 install ISO that includes Update 2,
- 40 minutes for the 800 Mb XE2 Help Update 1,
- 20 minutes for the 350 Mb RADPHP XE2 Update 2.
- The Update 2 install will wait a very long time in the “Validating” phase. Just be patient, it will get there in the end.
- Though the Help Update 1 is a lot bigger download, you usually only install one language and then it needs around half a gigabyte.
There are a ton of changes (154 changes files in the C:\Program Files (x86)\Embarcadero\RAD Studio\9.0\source directory tree alone) including some of the things I came across that now have been fixed:
- warnings about duplicate resources when including MidasLib
- refreshing of BindingList
- when the FireMonkey designer is visible, Alt-key combinations now work again
–jeroen
Via: Update 2 for Delphi XE2, C++Builder XE2 and RAD Studio XE2 now available – DelphiFeeds.com.
Posted in Delphi, Delphi XE2, Development, Software Development | 8 Comments »
Posted by jpluimers on 2010/05/11
This Why does this code fail in D2010, but not D7 question on stackoverflow once again shows that SizeOf on character arrays usualy is evil.
My point in this posting is that you should always try to write code that is semantically correct.
By writing semantically correct code, you have a much better chance of surviving a major change like a Unicode port.
The code below is semantically wrong: it worked in Delphi 7 by accident, not by design:
Like many Windows API functions, GetTempPath expects the first parameter (called nBufferLength) number of characters, not the number of bytes. Read the rest of this entry »
Posted in Delphi, Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi 3, Delphi 4, Delphi 5, Delphi 6, Delphi 7, Delphi XE, Delphi XE2, Delphi XE3, Development, Encoding, ISO-8859, Software Development, Unicode | Leave a Comment »
Posted by jpluimers on 2009/10/19
Operator overloading is a very nice feature of the Delphi language.
However. the Delphi documentation on Operator overloading is not completely right.
Below is my table of what I found out so far, and some notes.
It is part of my “Nullable types in Delphi” session that I gave on some conferences.
The downloads for that session contain more detailed information.
This is just an abstract to get you going and a try to answer this operator overloading question on Stackoverflow.
Download the full presentation to get more in depth information.
Let me know if you need more information.
Notes
Operator overloading
Add your own “behaviour” to operators
- Win32: Works only for records, not classes!
- An operator and the operand(s)
are being implemented worden by a “class operator”;
this is a kind of class method with name and argumen(s)
Example:
- Multiplication X : = A * B;
- Operator: *
- Name: Multiply
- Operands: 2 -> two parameters
type
TMyRecord = record
class operator Multiply(A, B: TMyRecord): TMyRecord;
end;
Documentation is not correct!
Combining the rules of operator and result types, you can do magical things like Dances with XML | Australian Delphi User Group Members.
Do not use Delphi 2006 with operator overloading
Delphi 2007 fixed a number of bugs including this one: Delphi 2006 wont allow const parameters of type record within record method? – Stack Overflow.
10+ years later: maybe assignment operator?
It might be that in 2019, a new Delphi version gets assignment operator overloading: [WayBack] Operator Overloading Explained – Code Partners
Watch the result type of comparison operators!
Tips:
- Some operators should be overloaded pair-wise
= and <>
shl and shr
< and >=
> and <=
dec and inc
+ and –
/ and *
div and mod
- Prefer Explicit over Implicit operators
- Beware of the built-in type coercion (implicit operators)
- e.g
- Byte to Integer;
- Integer to Double;
- Variants from/to anything!
Table of operators
| operator |
# |
usage |
name |
cagetory |
* |
| and |
2 |
R := A and B; |
BitwiseAnd |
bit |
|
| not |
1 |
R := not A; |
//BitwiseNot |
bit |
glitch: does not exist! |
| or |
2 |
R := A or B; |
BitwiseOr |
bit |
|
| xor |
2 |
R := A xor B; |
BitwiseXor |
bit |
|
| () cast |
1 |
R := TValue(A); |
Explicit |
conversion |
|
| := |
1 |
R := A; |
Implicit |
conversion |
|
| operator |
# |
usage |
name |
category |
* |
| round |
1 |
R := Round(A); |
Round |
function |
|
| trunc |
1 |
R := Trunc(A); |
Trunc |
function |
|
| and |
2 |
R := A and B; |
LogicalAnd |
logical |
|
| not |
1 |
R := not A; |
LogicalNot |
logical |
|
| or |
2 |
R := A or B; |
LogicalOr |
logical |
|
| xor |
2 |
R := A xor B; |
LogicalXor |
logical |
|
| operator |
# |
usage |
name |
category |
* |
| + |
2 |
R := A + B; |
Add |
binary |
|
| / |
2 |
R := A / B; |
Divide |
binary |
|
| div |
2 |
R := A div B; |
IntDivide |
binary |
|
| mod |
2 |
R := A mod B; |
Modulus |
binary |
|
| * |
2 |
R := A * B; |
Multiply |
binary |
|
| – |
2 |
R := A – B; |
Subtract |
binary |
|
| operator |
# |
usage |
name |
category |
* |
| shl |
2 |
R := A shl B; |
LeftShift |
binary |
name is confusing |
| shr |
2 |
R := A shr B; |
RightShift |
binary |
name is confusing |
| – |
1 |
R := -A; |
Negative |
binary |
|
| + |
1 |
R := +A; |
Positive |
binary |
|
| dec |
1 |
Dec(A); |
Dec |
self |
|
| inc |
1 |
Inc(A); |
Inc |
self |
|
| operator |
# |
usage |
name |
category |
* |
| = |
2 |
R := A = B; |
Equal |
comparison |
|
| > |
2 |
R := A > B; |
GreaterThan |
comparison |
|
| >= |
2 |
R := A >= B; |
GreaterThanOrEqual |
comparison |
|
| < |
2 |
R := A < B; |
LessThan |
comparison |
|
| <= |
2 |
R := A <= B; |
LessThanOrEqual |
comparison |
|
| <> |
2 |
R := A <> B; |
NotEqual |
comparison |
|
| operator |
# |
usage |
name |
category |
* |
| in |
2 |
R := A in B; |
In |
set |
|
–jeroen
Posted in Conferences, Delphi, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi XE, Delphi XE2, Delphi XE3, Development, Event, Software Development | 6 Comments »
Posted by jpluimers on 2009/10/15
Edit 20140822 since originally posting, JEDI moved to a GIT repository, so I changed some URLs and added that it is up to date until Delphi XE7.
Finding the correct VERxxx conditional define for a particular Delphi version is asked by a lot of people.
Even the first link in the above search, does not contain the full list!
But: JCL comes to the rescue
The JCL file JEDI.INC usually (read: like 99.999% of the time) is up to that with that information soon.
Currently, it contains all the defines starting with Delphi 1, up to Delphi 2010 XE7.
You can always browse the to JEDI.INC with this link to the sourceforge trunk. link to the GitHub master version.
In fact that file contains a lot more useful defines.
Actually, having the JCL and/or JVCL at hand is a very good practice: it is filled with high quality code that solves a lot of everyday problems.
Note:
VER190 (by some people attributed to the wrong Delphi version) is only used by Delphi 2007 for .NET (Delphi 2007 for Win32 used VER185 by itself and shares VER180 with Delphi 2006 for Win32).
The number 13 (in between Delphi 2009 aka Delphi 12, and Delphi 2010 aka Delphi 14) was never used as a Delphi version number
Since Delphi is mainly developed in the USA, and since a lot people there have Triskaidekaphobia, they showed mercy to those and skipped Delphi 13.
–jeroen
Posted in Delphi, Delphi 1, Delphi 2, Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi 3, Delphi 4, Delphi 5, Delphi 6, Delphi 7, Delphi 8, Delphi x64, Delphi XE, Delphi XE2, Delphi XE3, Delphi XE4, Delphi XE5, Delphi XE6, Delphi XE7, Development, Software Development | 9 Comments »