Archive for the ‘Delphi 2009’ Category
Posted by jpluimers on 2013/01/30
Just in case you wonder about Property using Generics in Delphi, they are not possible.
Thanks David for mentioning it, Hallvard for mentioning it even earlier and Rudy for confirming it.
These are supported with Generics in Delphi:
All of the supported aspects are linked to articles from excellent authors. There is far more on the internet about Delphi and Generics, but those are a good start.
Thanks Malcolm, Phil, Barry, Hallvard, Jolyon and many others for posting all those articles!
Note that this is not possible in C# either, Julian Bucknall organized a chat and explains why, but there is a workaround which I might try to port to Delphi in the future.
–jeroen
via: Property using Generics in Delphi – Stack Overflow.
Posted in .NET, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Delphi, Delphi 2009, Delphi 2010, Delphi XE, Delphi XE2, Delphi XE3, Development, Software Development | 3 Comments »
Posted by jpluimers on 2013/01/29
If Gloegg@Bonn has posted a few nice Delphi entries over the last couple of years, so he should be added to DelphiFeeds.
His last one was a very funny post on the Delphi implementation of Sleep sort.
It uses Generics, so you need at least Delphi 2009 or better.
–jeroen
via:
Posted in Delphi, Delphi 2009, Delphi 2010, Delphi XE, Delphi XE2, Delphi XE3, Development, Software Development | 4 Comments »
Posted by jpluimers on 2013/01/08
When developing in multiple languages, it sometimes is funny to see how they differ in compiler oddities.
Below are a few on const examples.
Basically, in C# you cannot go from a char const to a string const, and chars are a special kind of int.
In Delphi you cannot go from a string to a char. Read the rest of this entry »
Posted in .NET, ASCII, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Delphi, Delphi 2009, Delphi 2010, Delphi XE, Delphi XE2, Development, Encoding, Software Development, Unicode | Leave a Comment »
Posted by jpluimers on 2012/09/27
Cool: learned something new here:
About the path names of files being in the .dproj as well as in the .dpr:
@Jeroen – Looks like msbuild might need those entries, otherwise they’re possibly redundant, AFAICT… In any case, there is not much editing involved, just delete ‘dccreference’ entries and then a ‘save all’ in the IDE regenerates them. – Sertac Akyuz
–jeroen
via: refactoring – How to reorganize the folder structure of my units in Delphi? – Stack Overflow.
Posted in Delphi, Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi XE, Delphi XE2, Delphi XE3, Development, Software Development | Tagged: computer, Delphi, folder structure, ide, path names, stack overflow, technology | 14 Comments »
Posted by jpluimers on 2012/09/11
Today I found out the hard way that you really need a build integration system for managing VersionInfo in Delphi applications: as of Delphi XE2 it is broken in the IDE.
See these links:
This is the only workable workaround so far:
–jeroen
Posted in 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 | Tagged: application version, computer, Delphi, delphi applications, education, embarcadero, integration system, stack overflow, technology | 14 Comments »
Posted by jpluimers on 2012/09/10
Last week, ModelMaker Code Explorer 10.0.0 got released:
General new features
- Delphi XE3 / RAD Studio XE3 support
(as well as support from Delphi 5 and up)
- Member Search list allows filtering on member type. Todo items are also displayed.
- Pascal, new option on tab MMX | Properties | Pascal | New Entities | Methods: Empty Parameter lists. This controls how empty method, procedure and delegate parameter lists are emitted: either suppressed – pascal style, or emitted as ( ) – c-style.
- Locate Type: displays a filtered list of previously parsed class and interface types. This is used to open the containing source file and locate a class inside the file. Default key binding Alt+Shift+T.
Solved bugs
- Text containing line breaks and stored in XML (settings, snippets) could contain stray 0x0B (#11) characters. Solved.
- An access violation at shutdown could occur in older Delphi IDEs if MMX was not docked. Solved.
- If the Delphi IDE editor buffer contains a stray #0 (which is bad in itself) would cause all kinds of exception in MMX. MMX now detects stray #0’s and abort all editing operations, displaying the line:column of the bad #0 character.
- Pascal: relative paths starting with \ (relative to root in drive) would not be handled correct. Solved
–jeroen
via: ModelMaker Code Explorer 10.0.0.
Posted in Delphi, Delphi 2007, Delphi 2009, Delphi 2010, Delphi 5, Delphi 6, Delphi 7, Delphi XE, Delphi XE2, Delphi XE3, Development, Software Development | Tagged: access violation, c style, delegate, Delphi, delphi 5, delphi ide, editor buffer, empty parameter, interface types, line breaks, member search, member type, new features, new option, pascal, relative paths, snippets, software, technology | 2 Comments »
Posted by jpluimers on 2012/08/14
Last week I posted an in depth answer on StackOverflow.com about the memory allocation difference in Delphi and Fortran, or more accurately in two different kinds of languages.
You have:
- column major order (not only used in Fortran and other science centric languages, but also in the shading languages GLSL and HLSL that can be used in FireMonkey)
- row major order (used in most other languages, for instance Delphi, C, etc)
A very important aspect is the order of for optimized loops. For column major order, the optimum is inside out (as the inner arrays/records are in consecutive memory locations), but for row major order, it is the exact inverse.
One of the consequences is that in Fortran it is a very fast operation to pass an array of inner fields as parameter to a method.
This is what I wrote: Read the rest of this entry »
Posted in Delphi, Delphi 2007, Delphi 2009, Delphi 2010, Delphi for PHP, Delphi x64, Delphi XE, Delphi XE2, Development, Fortran, Software Development | 4 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 »