The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,839 other subscribers

Archive for the ‘Development’ Category

Delphi XE2 and iOS: things you should not do

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 »

Asphyre Sphinx 2: X-platform game development for Delphi XE2 and/or FPC

Posted by jpluimers on 2011/12/15

Just found out that during my holiday, Asphyre Sphinx 2 was released: a free 2D/3D framework for X-platform game development that comes with full source code.

It is based on FireMonkey supports Delphi XE2 Update 1 and up, and FPC (and yes: it supports on iOS too).

Interesting stuff!

–jeroen

Via: Asphyre Sphinx 2.

Posted in Delphi, Development, Software Development | Leave a Comment »

Overview of .NET Framework, CLR and Visual Studio version numbers – via StackOverflow.com

Posted by jpluimers on 2011/12/14

I love StackOverflow.com; since they clean out duplicate questions very well, it now is becoming a very good site for reference materials as well.

I won’t duplicate the tables of .NET CLR/Framework and Visual Studio version numbers here as it will age: the tables linked below will somehow be updated by someone. The real power of SO.

–jeroen

Via: How do the .NET Framework, CLR and Visual Studio version numbers relate to each other? – Stack Overflow.

Posted in .NET, Development, Power User, Software Development | Leave a Comment »

WinForms UserControl and Visual Studio 2010 debugging – The process cannot access the file … because it is being used by another process – Stack Overflow

Posted by jpluimers on 2011/12/13

When doing WinForms development in Visual Studio 2010 (including SP1), be aware of a bug with UserControls that hamper debugging; sometimes you get an error like this:

Error 9 Unable to copy file "obj\x86\Debug\MyProject.exe" to "bin\Debug\MyProject.exe". The process cannot access the file 'bin\Debug\MyProject.exe' because it is being used by another process.

When using SysInternals’ Process Explorer to see which process has handles open to MyProject, you will see that devenv.exe (The Visual Studio IDE) is the culprit: sometimes it has a lot of handles open.

The workaround is simple: close all UserControls before debugging your WinForms application.

A real pity, as UserControls are a very useful feature when developing software (many platforms use the same paradigm, .NET certainly wasn’t the first to introduce it, and it is available in for instance WPF as well).

Note that there are other causes of the same error message, but for me this was the issue.

–jeroen

Via: visual studio 2010 – VisualStudio2010 Debugging – The process cannot access the file … because it is being used by another process – Stack Overflow.

Posted in .NET, C#, Development, Software Development, VB.NET, Visual Studio 2010, Visual Studio and tools | 2 Comments »

Restarting InterBase from the command-line on Windows and Mac

Posted by jpluimers on 2011/12/08

I recently wrote this script for like the upteenth time, so now it is on bo.codeplex.com and in my BIN directory on Windows and in my sh directory on my Mac.

Note for the scripts in this post:

Windows

restart-InterBase.cmd:

net stop IBG_gds_db
net stop IBS_gds_db
net start IBG_gds_db
net start IBS_gds_db

It restarts only the default instance.

Usually it is enough to restart the Guarduan (IBG_gds_db), but sometimes that hangs, so I restart both the Guardian and the DB service (IBS_gds_db).

You can do the same with Firebird of course, and adapt for non-default instances: just find the right service names using a script like this:

sc query

then search the output for entries matching InterBase or Firebird like these:

SERVICE_NAME: IBG_gds_db
DISPLAY_NAME: InterBase XE Guardian gds_db
        TYPE               : 10  WIN32_OWN_PROCESS
        STATE              : 4  RUNNING
                                (STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0

SERVICE_NAME: IBS_gds_db
DISPLAY_NAME: InterBase XE Server gds_db
        TYPE               : 10  WIN32_OWN_PROCESS
        STATE              : 4  RUNNING
                                (STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
        WIN32_EXIT_CODE    : 0  (0x0)
        SERVICE_EXIT_CODE  : 0  (0x0)
        CHECKPOINT         : 0x0
        WAIT_HINT          : 0x0

Mac OS X

You can find the name of your Interbase service when you look at the user-installed services:

bash-3.2$ cd /Library/StartupItems/InterBase_gds_db/
bash-3.2$ ls -l
total 16
-rwxr-xr-x  1 root  wheel  636 Oct 21 15:44 InterBase_gds_db
-rwxr-xr-x  1 root  wheel  204 Sep 14  2007 StartupParameters.plist
bash-3.2$ cat StartupParameters.plist
{
  Description     = "InterBase Server";
  Provides        = ("InterBase Database Server");
  Requires        = ("DirectoryServices");
  Uses            = ("Disks", "NFS");
  OrderPreference = "None";
}
bash-3.2$

You can restart the InterBase Database Server using this command:

sudo SystemStarter -vdD restart "InterBase Database Server"

The SystemStarter -vdD parameters make the output add verbose, debugging information and dependencies.
–jeroen

Posted in Database Development, Development, InterBase | Leave a Comment »

Trouble with Google Reader and GEXperts RSS feed :)

Posted by jpluimers on 2011/12/07

While catching up my feeds after an astonishing holiday around the Antarctic Peninsula (some photos at Flickr), I bumped into a Google Reader issue with the GExperts.com RSS feed: all posts seem to be stamped 20111117T0555.

Funny, as I remember being late to report GExperts 1.35 for Delphi XE2 was released a while a go :)

It reminded me to ask Thomas to publish the XE2 version of his Experimental GExperts build though.

Lets hope he is faster than me catching up :)

--jeroen

via: Google Reader feed for GExperts.org.

Posted in About, Antarctic, Delphi, Development, Personal, Software Development, Travel | 7 Comments »

SQL Server inverse of (equals) is ((not equals) or (is NULL)

Posted by jpluimers on 2011/12/07

Usually getting queries right with SQL Server comes down to handling NULL correctly.

For instance, on this table:

MYTABLE
ID LAST_NAME
6 COUNT(*)
1 FOO
2 BAR
3 FOO
4 **NULL**
5 BAR
6 FOO

What are the results of these SELECT statements

SELECT COUNT (*)
FROM MYTABLE

SELECT COUNT (*)
FROM MYTABLE
WHERE     (LAST_NAME = 'FOO')

SELECT COUNT (*)
FROM MYTABLE
WHERE     (LAST_NAME <> 'FOO')

SELECT COUNT (*)
FROM MYTABLE
WHERE     NOT (LAST_NAME = 'FOO')

You might think they are like these, as LASTNAME <> ‘FOO’ looks like the inverse of LASTNAME = ‘FOO’:

  • 6
  • 3
  • 3
  • 3

But in fact the results are these:

  • 6
  • 3
  • 2
  • 2

When you look closely to the SQL statements below, you will see that the inverse of EQUALS contains an IS NULL, the same for the inverse of NOT EQUALS:

SELECT COUNT (*)
FROM MYTABLE

-- inverse of NOT EQUALS
SELECT COUNT (*)
FROM MYTABLE
WHERE     (LAST_NAME = 'FOO') OR (LAST_NAME IS NULL)

SELECT COUNT (*)
FROM MYTABLE
WHERE     (LAST_NAME <> 'FOO')

SELECT COUNT (*)
FROM MYTABLE
WHERE     (LAST_NAME = 'FOO')

-- inverse of EQUALS
SELECT COUNT (*)
FROM MYTABLE
WHERE     (LAST_NAME <> 'FOO') OR (LAST_NAME IS NULL)

-- inverse of EQUALS
SELECT COUNT (*)
FROM MYTABLE
WHERE     (NOT (LAST_NAME = 'FOO')) OR (LAST_NAME IS NULL)
  • 6
  • 4
  • 2
  • 3
  • 3
  • 3

Lesson learned: always take into account NULL when trying to formulate your SQL comparisons well.

–jeroen

Posted in Database Development, Development, SQL Server, SQL Server 2000, SQL Server 2008 | Leave a Comment »

When writing applications, include Keyboard Shortcuts for both the CUA and Windows/Apple shortcuts

Posted by jpluimers on 2011/12/06

When you write applications, it is important to include both the CUA and the Windows/Apple keyboard shortcuts, and get the tab order of keyboard accessible user elements right.

Many modern applications seem to put less and less emphasis on the most efficient user input device: the keyboard.

You should: it makes your application much more pleasant to use.

I wrote about CUA before, but the Windows and Mac shortcuts are just as important.

A small table (please post a comment if you know additions):

Read the rest of this entry »

Posted in .NET, Delphi, Development, Hardware, IBM SAA CUA, Keyboards and Keyboard Shortcuts, KVM keyboard/video/mouse, Power User, Software Development, xCode/Mac/iPad/iPhone/iOS/cocoa | Leave a Comment »

Source Code Pretty Printing in various languages

Posted by jpluimers on 2011/12/05

Totally forgot about this: YAPP – yet another pretty printer.

–jeroen

via: delphi – Save source code with formatting syntax highlight – Stack Overflow.

Posted in .NET, C#, Development, Prism, Software Development | Leave a Comment »

File Extensions of Files Generated by RAD Studio – RAD Studio XE2

Posted by jpluimers on 2011/12/01

With Delphi 1, it was easy to choose what to put in your version control systems: basically .pas, .dfm, .dpr, .inc, .res, .cfg and you were set.

Now there are many more extensions involved, so it is harder to choose what to put in your version control system and what not.

The File Extensions of Files Generated by RAD Studio page helps you with that: it lists most of the Delphi file extensions (.local is a noticeable exception) that are used today.

–jeroen

via: File Extensions of Files Generated by RAD Studio – RAD Studio XE2.

Posted in Delphi, Development, Software Development | 4 Comments »