Archive for the ‘Development’ Category
Posted by jpluimers on 2013/04/04
Thanks Jeb for answering this:
You can solve it with delayed expansion, because delayed expansion works different than percent expansion.
:START
setlocal EnableDelayedExpansion
@echo What folder do you want to process? (Provide a path without a closing backslash)
set /p datapath=
::Is string empty?
IF X!datapath! == X GOTO:START
::Does string have a trailing slash? if so remove it
IF !datapath:~-1!==\ SET "datapath=!datapath:~0,-1!"
echo !datapath!
It expands later than the percent expansion, and after the delayed expansion no more parsing is done, so even spaces or special characters have any effect.
–jeroen
via:
Posted in Batch-Files, Development, Power User, Scripting, Software Development | Leave a Comment »
Posted by jpluimers on 2013/04/03
Just found this great answer by vcldeveloper to autoscroll a readonly logging memo in Delphi which works from Delphi 1 and up (:
For such a simple task, you don’t need to buy a commercial component! All you need to do is to send an EM_LINESCROLL message to that memo control, to make it scroll to the last line:
procedure ScrollToLastLine(Memo: TMemo);
begin
SendMessage(Memo.Handle, EM_LINESCROLL, 0,Memo.Lines.Count);
end;
If your memo is read-only to users and is updated automatically by the application, you can put a call to the above procedure in its OnChange event-handler, so that whenever the text inside the memo is changed, it is automatically scrolled down to the last line.
–jeroen
via: autoscrolling memo in delphi – Stack Overflow.
Posted in Delphi, Delphi 1, Delphi 2005, Delphi 2006, Delphi 2007, Delphi 2009, Delphi 2010, Delphi 3, Delphi 4, Delphi 5, Delphi 6, Delphi 7, Delphi x64, Delphi XE, Delphi XE2, Delphi XE3, Development, Software Development | 9 Comments »
Posted by jpluimers on 2013/04/02

IGrouping interface diagram (click to enlarge)
One of the things most people find hard to use in LINQ is GroupBy or the LINQ expression group … by (they are mostly equivalent).
When starting to use that, I was also confused, mainly because of two reasons:
- GroupBy returns a IGrouping<TKey, TElement> generic interface, but the classes that implement it are internal and not visble from outside the BCL (although you could artificially create your own).
This interface extends the IEnumerable<TElement> in a full “is a” fashion adding a Key member.
This has two consequences:
- Because it is a “is a” extension of the IEnumerable<TElement>, you can use foreach to enumerate the
TElement members for the current group inside the grouping.
No need to search for a Value that has the Elements, as the Group is the Elements.
- The Key member is indeed the current instance of what you are grouping over. Which means that Count<TElement>, are for the current group in the grouping.
- The LINQ expression syntax for grouping on multiple columns is not straightforward:
- Grouping on multiple columns uses a bit different syntax than you are used from SQL.
(Another difference is that SQL returns a set, but groups are IEnumerable)
- You also need to be a bit careful to make sure the group keys are indeed distinct.
Most people don’t see the IGrouping<TKey, TElement> because they use the var keyword to implicitly the LINQ result.
Often – when using any anonymous type – var is the only way of using that result.
That is fine, but has the consequence that it hides the actual type, which – when not anonymous – is a good way of seeing what happens behind the scenes.
David Klein gave an example for the multi column grouping and also shows that if you use LINQPad, you can actually see the IGrouping<TKey, TElement> in action.
Mike Taulty skipped the Group By Syntax for Grouping on Multiple Columns in his Grouping in LINQ is weird (IGrouping is your friend). So my examples include that.
Note that I don’t cover all the LINQ group by stuff, here, for instance, I skipped the into part.
There are some nice examples on MSDN covering exactly that both using Method based and Expression based LINQ.
The examples are based on these two classes, similar to what Mike did. Read the rest of this entry »
Posted in .NET, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 3.0, C# 4.0, C# 5.0, Development, LINQ, Software Development | Leave a Comment »
Posted by jpluimers on 2013/03/29
Als je postcode “1060 NP” invult bij aansluiting en “1170 AB” bij facturatie, dan krijg je deze onterechte foutmeldingen:
- Organisatie postcode is ongeldig
- Facturatie gegevens postcode is ongeldig
Beetje vreemd, want al sinds de introductie van postcodes in Nederland in 1978 zit in een postcode 1 spatie, en tussen de postcode en de woonplaats 2 spaties.
Ook trema‘s gaan mis: bij postcode 1060 NP hoort de straat Pyreneeën in Amsterdam, maar bij Heldenvan.nu wordt het deze Mojibake:
Read the rest of this entry »
Posted in Development, Encoding, Mojibake, Opinions, Power User, Software Development, Unicode | Leave a Comment »
Posted by jpluimers on 2013/03/28
There are a couple of very interesting libraries and ideas every Delphi developer should take a look at.
The list is far from complete, but should give you a good overview on what more recent Delphi language additions like attributes, generics, helpers, overloading, are capable of.
–jeroen
Posted in Delphi, Delphi 2009, Delphi 2010, Delphi XE, Delphi XE2, Delphi XE3, Development, Software Development | 3 Comments »
Posted by jpluimers on 2013/03/27
I was amazed that this is still usable:
You can even run VMware Fusion 4 full screen at 2880×1800, but I prefer to have the Mac Desktop and Dock to be visible. I didn’t have any of the VMware Fusion 4 issues mentioned here.
So the only thing you need VMware Fusion 5 for is Windows 8 support.
You need SwitchResX to get the Retina MacBook to use 2880×1800 at all (otherwise you get 1920×1200 at 1.5 scale factor, which is also a 16:10 display ratio).
It really runs 5+ hours on one battery charge, which is much longer than my ThinkPad W701.
All in all, I’m very happy with this setup.
--jeroen
PS:
via: Screen Shot 2013-03-27 at 19.55.39 | Flickr – Photo Sharing!.
Click on the image or here for full size image.

Posted in Apple, Delphi, Delphi XE3, Development, Mac, Mac OS X / OS X / MacOS, MacBook, MacBook Retina, OS X 10.8 Mountain Lion, Power User, Software Development | 7 Comments »
Posted by jpluimers on 2013/03/27
As I wrote before, I’m with the [WayBack] Delphi with haters camp, and this is why:
Using the [WayBack] with statement in Delphi makes your code less future proof.
Originally, the with statement in Pascal was argumented in part of allowing compiler optimisations:
PASCAL User Manual and Report – Kathleen Jensen, Niklaus Wirth – Google Books
The with clause effectively opens the scope containing field identifiers of the specified record variable, so that the field identifiers may occur as variable identifiers. (Thereby providing an opportunity for the compiler to optimize the qualified statement.)
Screenshots of this 1975 book are below the fold.
The Delphi (actually even before that Turbo Pascal compiler) has no measurable difference between with and non-with code.
The debugger however, still does not support with, and there are other drawbacks of which one is below.
The below code example is just one of many. I show it because I recently bumped into doing some long overdue code porting to Delphi XE3.
Since I’ve been bitten by using with a couple of times before, it didn’t take me long to find the cause.
Example code where FIConData is of type NOTIFYICONDATAW that used to compile fine:
with FIconData do
begin
cbSize := SizeOf(FIconData);
Wnd := Self.Handle;
uID := $DEDB;
uFlags := NIF_MESSAGE or NIF_ICON or NIF_TIP;
hIcon := Application.Icon.Handle;
uCallbackMessage := WM_CAS400NTIcon;
StrCopy(szTip, PChar(Caption));
end;
Well, as of Compiler Version 20, it doesn’t compile any more. Read the rest of this entry »
Posted in Borland Pascal, Conference Topics, Conferences, Delphi, Delphi 1, 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, Event, Pascal, Software Development, Turbo Pascal, With statement | 32 Comments »
Posted by jpluimers on 2013/03/26
While porting a library from Delphi 2006 to Delphi XE2.
The really cool thing is that the Windows Event Log contains details of what I did wrong (:
–jeroen
Posted in Delphi, Delphi XE2, Development, MQ Message Queueing/Queuing, Software Development, WebSphere MQ | Leave a Comment »
Posted by jpluimers on 2013/03/22
Als je een mail krijgt als onderstaande, dan weet je dat er iemand niet heeft opgelet bij het maken en controleren van de e-mail templates:
from: noreply@agentschapnl.nl
Geachte ${naam},
Uw mededeling WBSO/RDA 2012 voor is ontvangen op 22-03-2013 18:11.
Alleen als er sprake is van een correctie op de afgegeven WBSO verklaringen en/of RDA beschikkingen ontvangt u hiervan schriftelijk bericht.
In uw ingediende mededeling kunt u zien of er sprake is van een correctie.
Met vriendelijke groet,
Agentschap NL
(Deze e-mail is automatisch gegenereerd en kan niet worden beantwoord.)
–jeroen
via Bevestiging Mededeling WBSO RDA 2012 – jeroen.pluimers.com@gmail.com – Gmail.
Posted in User Experience (ux) | Leave a Comment »