You are browsing the archive for Donald Shimoda [TeamRO].

Migrating from Delphi to Lazarus

September 9, 2008 in Delphi, Free Pascal, Linux

Not to me on time, even to this boring, but again I got a challenge on my shoulders is really difficult to meet.

The fact is migrating an application from Delphi to Lazarus is easy, by the way, but specifically this beautiful Delphi library im wornking on make a heavy use of Windows API messages…

Reviewing the steps to begin to migrate an application to Delphi Lazarus are very simple.

1) Create a new structure, independent of the one containing the Delphi application, so that you touches does not affect your Delphi application (is basic but very few do it).
2) For each Delphi project file (only for the dpr)

makepasx Proyect1.dpr

3) For each .pas file executes the following command

makepasx unit1.pas

4) For each delphi form execute this command

dfmtolfm unit1.dfm

5) Lazarus uses a resource file for each form, with extension lrs. To generate:

lazres unit1.lrs unit1.lfm lazres unit1.lrs unit1.lfm

Made. We already have everything we need to take the first step in our journey of 1000 miles (the more important).Now just compile and see what happens.

Usually some functions or calls vary somewhat between Delphi and Lazarus. It could put some of them here, but it makes no sense because they are many. Instead I will give you a way to resolve discrepancies in the simplest way, or by various methods that generally make me reach the correct result:

1) If you can not find an identifier or method just look in the sources references in the sources of Lazarus. Sounds silly? Is the simplest way, this way you can know that unit is defined and objects that use it.

2) If the identifier or method does not exist in lazarus, go to the forums Lazarus and looking for. Sure someone before you crash with that stone and found how to setp out ;)

3) If none of that works, the friend google comes to the rescue. You might try Lazarus discrepantname or add the word replacement, and so on.

Finally, as the case may happen in the library that attempt to migrate, that there are too many calls to the Windows API. In this case point 2 and 3 are generally much help.

4) Subscribe to groups Lazarus and fpc. Who better than those who have already been there can help you? Even if a feature is not suported they will help you to implement it and produce the miracle of Lazarus and fpc library get enriched. :)

In other deliveries i will comment about my progress in the conversion and as the problems were resolved.

Namaste.

Going from Delphi to FPC/Lazarus, my first steps

April 13, 2008 in Delphi, Free Pascal

After analize my options to migrate from win32 to linux some Object pascal projects, and under take little test i finally get the trip. My choice is to give a try to FPC/Lazarus. :)

I start migrating a server from Delphi/Win32 to FPC/Linux that weekend.

The first thing i do is get the latest beta version of RO/DA libraries for FPC and make it compile under lazarus. After a little work i have RO/DA in my lazarus palette. Happiness!

RemObjects SDK palette

RemObjectsinLazarus_Short

Data Abstracts palette

DataabstractinLazarus_Short

Next, i copy all my sources to a new folder, allowing to advance in my experiment with peace of mind. :)

Lazarus IDE have severals experts to do that help that job. One is the delphi project converter. I try that and the result was part of the project work and another forms complains about strange chars in several dfms , maybe because of the spanish language used in mostly of them.

So, i start the manual process. First converting DFM files to LFM files, and then editing all my units to make it FPC friendly.

The process is almost trivial, the main points you must have in account are:

1) Most of third parties components are delphi/windows related, so before start the process get out that libraries of
your code or you will have several headaches.
2) Activate Delphi mode in the project options. In my experience i also must do in the unit itself {$MODE delphi}
3) Add to your unit a def to change between LResources unit and windows unit. Example:

unit fServerForm;

{$ifdef FPC}
{$MODE delphi}
{$endif}

interface

uses
{$ifdef FPC}
LResources,
{$else}
windows,
{$endif}
uDAMemDataTable;

type

I put whenever i can defines.My idea is maintain a unique code base, merging that experiment with the project delphi codebase when work done.

4)Remove or embrace in ifdef the *.dfm line.

{$ifndef FPC}
{$R *.dfm}
{$endif}

5) If already no defined add initialization section including lrs files.

initialization
{$i aService_Impl.lrs}

6) Threading is a little diff,example;

{$ifdef FPC}
InitCriticalSection(aCriticalSection);
{$else}
InitializeCriticalSection(aCriticalSection);
{$endif}

TryEnterCriticalSection not implemented, use EnterCrticialSections instead.

{$IFDEF FPC}
DoneCriticalSection(aCriticalSection);
{$ELSE}
DeleteCriticalSection(aCriticalSection);
{$ENDIF}

7) Fomclose have slightly diff params.

{$ifdef FPC}
procedure TfmInputOutput.FormClose(Sender: TObject;
var CloseAction: TCloseAction);
{$else}
procedure TfmInputOutput.FormClose(Sender: TObject; var Action: TCloseAction);
{$endif}
begin
Poweroff;
end;

I think is invaluable the possibility of compile native servers, cross platforms using remobjects framework. Is worth the effort to make it works.
I love Delphi, but in the meantime, while codegears shareholders or anyone taking the path to other platforms give the needed step i will give a try to Lazarus.

What do you think? Is some of the several platforms offered by FPC a need for you in the short time?
I appreciate any comments.

Delphi 2007 IDE incompatible with Virtualbox

April 8, 2008 in Delphi, Linux

Bad news. VirtualBox version 1.5.6 eats 30-45% of cpu time when you start Delphi 2007 IDE.

The problem is related to a need for the IDE of higher timer resolution than provided by the OS (Ubuntu in my case).

According to a developer of Virtualbox:

‘Your guest uses a 1kHz timer, whereas your host probably just provides 250Hz resolution. so 1.5.6 uses a rather expensive way (busy waiting) to emulate proper timing. there isn’t much that can be done. 1.6 (whenever it’ll be out) will be slightly better, but probably not all that much. try to find out what windows app requires that 1kHz timer resolution. by default windows xp…
…just uses a 100Hz timer. ‘

Just to warn to Virtualbox + Delphi users. There’s no workaround rigth now. :-/

BTW, VMWare don’t suffer of that ‘problem’.

Codegear Developer Day 2 in Buenos Aires

October 26, 2007 in Delphi, non-tech

I meet David I, Andreano Lanusse and Andhers Ohlsson today. David I expose many points about the Codegear vision of the future.

David I, Me and Anders
(I’m the tall guy) ;)

First, they expose in a clear way Codegear is comited to NATIVE code, and will be there for years to come. They also work with dot net, off course but they plan to enhance native code via Delphi and C++.

The main point of enhance are:

a) Multicore support.
b) 64 bits compilers.
c) Unicode support.
d) C++ new standard support.

When asked about linux they clearly expose will be in a future a cross compiling compiler and rtl, not only for linux (?). But seems like happen after the other goals are reached.

In the dot net side, he say will enhance the integration trough VCL.NET, always. That way they will not force the VCL framework to the changes in technologies makes in Microsoft. Don’t will make any coments about that. :roll:

Finally, i discover Andreano Lanusse is a real PUMA, and a very very fun of Argentina. Im happy for that. :D

Andreano is a Argentinan Rugby Fun!

BTW, when i show the pic to my little daughter she said : Dad! Did you really meet Santa Claus? (Papa Noel in Argentina). :P

Link to Unisolutions oficial partner in Argentina with more pictures.

Enjoy!

Using Ubuntu like host OS

October 1, 2007 in Linux

Hi finally take the trip and after a lot of troubles with D2007 Updates and XP i prefer to use a Virtual machine running XP on a Ubuntu Box.

That way will guarantee after any problem i will always have a backup copy of a working VM , and can work again in just a few minutes.

The last time i try that, i must say, was a bad experience. VMWare lack of of a good communication between Host OS (LINUX) and VM. That was at beta 4 of VMWare i think. And the virtualizer options lack of many other features.

I hear about VirtualBox and think is a great chance to give a try.

I have to say i was surprised. VirtualBox is a OS app wich integrate lovely with Ubuntu Desktop. BTW, ubuntu grow up and is a really ‘just work’ distro. I have a HP dv9233cl notebook, and ALL the hardware works out of the box, except the web cam, working thanks to a easy to install core module.

VirtualBox offer a seamless mode, and i take some pictures from you.

I hope you like.

D2007 Update 3 Start.

Delphi 2007 ubuntu Box

BTW, the image on the background is a forest in the Patagonia Argentina, taked in my last vacation

D2007 Coding a Remobjects Solution

Delphi 2007 Ubuntu box 2

Any comments apreciated.

Going from Windows only to anywhere with RemObjects.

June 10, 2007 in Data Abstract, Delphi, Free Pascal, Linux

My current challenge is to migrate a RemObjects SDK server working in Win32 Delphi/VCL to Linux.

I am analyzing the technology to use. A few months ago I had only one option: Chrome/Mono.
I am not displeased because I now have an additional option and, because of it, I am pleased with RemObjects. If there is something that defines the technologies that RemObjects offers, it is in giving options to the developer.

Provided that Remobjects’ next version named ‘Vinci’ brings support to Free Pascal Compiler, now I can choose to use this tecnology or Chrome/Mono.

The server to migrate is a RemObjects SDK server working 24x7x365. The tasks that it fulfills are sophisticated and are mission critical:

  • Control of industrial hardware in real time across serial ports (using Async 32).
  • Control of industrial hardware in real time across ethernet UDP (using Synapse with self build threading).
  • Remote access to information and business tier (RemObjects SDK / Data Abstract).
  • Visualization of objects used in the industrial control through RemObjects’ message tiers.

All that stuff is separated in own and shared tasks, with communication channels via RemObjects SDK version 4.

Stay tuned, I will present a report of my selection and the justification.

My first step will be to migrate from Remobjects Version 4 to VINCI, the new and exciting technology offered by RemObjects.

Meanwhile, I will cetainly listen to ideas. Open for discussion!

Nice to meet you

June 10, 2007 in non-tech, Personal

Hi! My name is Donald and I am the CTO of a company that produces software for the retail sector.

From 1983, the year when I first touched a computer, I have never been separated from them.
I live most of time in San Isidro Argentina, and the rest in Bogota, Colombia and other parts of the world where our company is affiliated.

I hope that this will be a space for mutual growth for all developers interested in the incredible RemObjects technologies!