Sunday, December 27, 2009

Delphi Unicode Migration Whitepaper

About half way through a whitepaper by Cary Jensen entitled Delphi Unicode Migration for Mere Mortals: Stories and Advice from the Front Lines. Great paper. If you're doing Delphi development I think it's one of the best whitepapers I've read in quite some time.


About The Author

Ron Grove draws on over ten years of training, network administration and development experience. He loves to work with new technology and see how that technology can be best utilized by his clients. You can find him through his company Evanoah, LLC or through his LinkedIn profile.

Sunday, December 13, 2009

Using the QT interface with Lazarus on OS X

I noticed that QT 4.6 was released this month and figured I'd update my 4.5.1 install. After downloading and installing I couldn't recall the last time I had tried compiling Lazarus with the QT interface rather than the Carbon one. Since Carbon isn't making the 64 bit jump I'd prefer to use the 64 bit capable QT. I was happy to see that the status page for components lists QT as more complete than Carbon was. I went to the FPC QT4 Bindings homepage and downloaded the latest version of 1.72. It didn't list QT4.6 as being supported so I did a little searching on the Internet. I was happy to see a couple folks who said it compiled just fine on FreePascal and Lazarus email groups. The Mac compile command that's listed on the site worked like a charm:

make clean all LCL_PLATFORM=qt OPT="-k'-framework' -k'Qt4Intf' -k'-lobjc' -k'-framework' -k'Foundation'"

I've played around with all the standard components and some of them look better than their Carbon counterparts IMHO. The TButton looks much better than it does for the Carbon interface for example. I look forward to seeing how things develop in the future.


About The Author

Ron Grove draws on over ten years of training, network administration and development experience. He loves to work with new technology and see how that technology can be best utilized by his clients. You can find him through his company Evanoah, LLC or through his LinkedIn profile.

Thursday, December 10, 2009

A Basic Delphi RemObjects DataAbstract ROZeroConf tutorial

Yesterday I did a short tutorial on getting up and running with the base RemObjects SDK. Today's short tutorial will be on how to get a basic DataAbstract server started with ROZeroConf capabilities.
  1. Run the DataAbstract login server wizard. First I named the project "DelphiDAZeroConfTest". I then went into the advanced section and named the service "DAZeroConfTestService" and the library "DAZeroConfTestLibrary".
  2. We'll connect to the PCTrade database. I'm using the one in my SQL Server 2005 install. If you have that, fine, or perhaps you can use the SQLite PCTrade database that comes with the product.
  3. Add TDAZeroConfRegistration to your fServerDataModule.
  4. Attach it to the Server component on the same DataModule.
  5. Go to the "RemObjects SDK" menu item in Delphi and select "Regenerate Units from RODL".
  6. Uncomment the RegisterForZeroConf() function in your _Impl file. It's named DAZeroConfTestService_Impl.pas in my test project.
  7. Copy the second parameter for the RegisterForZeroConf function, which is a string, to the clipboard. In this sample it's _DAZeroConfTestService_rosdk._tcp.
  8. Open the client form and add a TROZeroConfBrowser component to it.
  9. Paste the string you copied in step 6 into the "ServiceType" property.
  10. Set the Active property to True.
  11. Set the Domain property to "local."
  12. Add a TMemo to the form and align it where you want to. It's aligned to the top in this test.
  13. Select the TROZeroConfBrowser component again and go to the events tab in the Object Inspector.
  14. We're going to create two event handlers. One for OnServiceAdded and one for OnServiceRemoved
  15. Add code to OnServiceAdded event handler
    if aRecord.TryResolve  then  
    begin
      Memo1.Lines.Add(Format('Service resolved. Host name: %s Port number: %d', [aRecord.HostTarget, aRecord.Port]));
    end;
    
  16. Add code to OnServiceRemoved event handler
    Memo1.Lines.Add(Format('Service has gone down: %s (at host %s:%d)',
                            [aRecord.ServiceName,
                             aRecord.HostTarget,
                             aRecord.Port]));
    
  17. Compile the server and launch it
  18. When the client comes up login with the same username and password
  19. After it logs in you should see something liek the following in your memo field:
    "Service resolved. Host name: vmware-devel.local. Port number: 8099"
  20. If you close the server application the memo field should have something like the following added:
    Service has gone down: vmware-devel (at host vmware-devel.local.:8099)
  21. If you restart the server the memo field should acknoledge it resolved, and visa versa.
Now we'll get some data from the server
  1. Add a button and call it "Load Emps" and name it btnLoadEmployees
  2. Double click the button to add an event handler and add the code:
    ClientDataModule.tbl_Employees.Active := True;
  3. This isn't what I'd do in a real app of course, but for this demo we're going to have the DBGrid clear when ROZeroConf notifies us the server has gone down. To do that I'm going deactivate tbl_Employees in the OnServiceRemoved event handler like this:
    ClientDataModule.tbl_Employees.Active := False;
  4. Now we'll drop a DBGrid onto the client form and set its DataSource to ClientDataModule.ds_Employees. I've set it to align to the bottom of the form for this test.
  5. Launch the server and then launch the client. You should be promted to login of course. Once you're logged in you should see the TMemo notify you that it's connected to the server with a message like this:
    "Service resolved. Host name: vmware-devel.local. Port number: 8099"
  6. Go ahead and click the "Load Emps" button. We should see data.
  7. Close the server and you should be notified that the server is down with a message like this:
    "Service has gone down: vmware-devel (at host vmware-devel.local.:8099)"
  8. Restart the server and try to load the data. It should blow up with an EROSessionNotFound Exception.

Of course we'll want to catch that and prompt for the user to login again. Let's change the btnLoadEmployees event handler to the following:
try
  ClientDataModule.tbl_Employees.Active := True;
except
  on EROSessionNotFound do begin
    if self.Login then
      ClientDataModule.tbl_Employees.Active := True;
  end;
end;

Recompile the client and try 1-8 again. This time we handle the exception and it prompts us to login again. Once we do that the data comes back. You'll probably want to catch other exceptions here as well like EROExceptions that are raised when the server isn't available at all. But this should get you started down the right path.

The Delphi 2010 project can be downloaded here.


About The Author

Ron Grove draws on over ten years of training, network administration and development experience. He loves to work with new technology and see how that technology can be best utilized by his clients. You can find him through his company Evanoah, LLC or through his LinkedIn profile.

Wednesday, December 9, 2009

A basic RemObjects SDK ROZeroConf tutorial

I was recently asked about the RemObjects SDK ROZeroConf capabilities in Delphi. I hadn't actually played with it yet, particularly in Delphi since I've mostly been doing .NET work of late. They do have the BonourDiscovery sample project, but if you you're like me you may prefer to read a little before trying to follow code, particularly if you're new to the component suite and already have the usual learning curve to follow. You also don't know what was added when, and you may miss important component properties if they aren't highlighted or done in code. The wiki article is a little slim and not always easy to follow since it includes both Delphi and .NET instructions. It's a new feature so I'm sure documentation will improve in time, but here's a start to finish barebones sample from scratch:
  1. Create a new RemObjects SDK VCL Server project using the wizard. I named my project ROZeroConfTest. Make sure you do create the client project as well. It's checked by default. I went into the advanced options of the wizard and renamed NewLibrary to ROZeroConfLibrary. I also renamed NewService to ROZeroConfService. Finish the wizard and your base project will be created.
  2. On your client application's form (which comes up first by default) add a ROZeroConfBrowser component from the RemObjects SDK component group.
  3. In the properties list set Domain to local. and set the Active property to True.
  4. Add a TMemo component to the client form and align it to the client.
  5. Open your server form and add a ROZeroConfRegistration component to it.
  6. In the Properties list set Server to your server component. It's probably named ROServer by default, and if you took the default configuration in the wizard it's probably of type TROIndyHttpServer.
  7. In the Project Manager make the server project active. Then go to the RemObject SDK menu in Delphi and select Edit Service Library. You'll see it has the usual Sum and GetServerTime test methods that all default project have. Add more if you like, but for this sample we'll just leave the defaults.
  8. Go to the RemObjects SDK menu and select Regenerate Units from RODL. This will launch a wizard. Just say OK to the default selection of Remobjects SDK Remote Datamodule.
  9. Open the code of your _Impl file, in the case of this sample it's named ROZeroConfService_Impl, and uncomment the RegisterForZeroConf function in your Initialization section.
  10. The second parameter to the RegisterForZeroConf function is a string containing your services name. In this sample it's _ROZeroConfService_rosdk._tcp.. Copy that string and open your client form. Select the ROZeroConfBrowser component and paste that string into the ServiceType property.
  11. While you still have the ROZeroConfBrowser component selected go to the Events tab in the Object Inspector. We're going to add two event handlers. One for OnServiceAdded and one for OnServiceRemoved
  12. Add the following line to your OnServiceAdded event:
    Memo1.Lines.Add(Format('Service resolved. Host name: %s Port number: %d', [aRecord.HostTarget, aRecord.Port]));
  13. And we'll add this line to the OnServiceRemoved event:
    Memo1.Lines.Add(Format('Service has gone down: %s (at host %s:%d)', [aRecord.ServiceName, aRecord.HostTarget, aRecord.Port]));

Assuming I got all the steps in there properly you should be able to compile and start your server application. Then start your client application. The client should register and add a line to your memo field saying something like this:

"Service resolved. Host name: vmware-devel.local. Port number: 8099"

If you close the server down, the client should add a line to the memo field that says something like this:

"Service has gone down: vmware-devel (at host vmware-devel.local.:8099)"

Hope that helps someone, at least until theres more information about these new features on the RemObjects wiki. The Delphi 2007 project can be downloaded here.


About The Author

Ron Grove draws on over ten years of training, network administration and development experience. He loves to work with new technology and see how that technology can be best utilized by his clients. You can find him through his company Evanoah, LLC or through his LinkedIn profile.

Friday, November 6, 2009

Installing into Boot Camp is a pain

I finally picked up a copy of Windows 7 and decided I'd like to use the 64 bit version in Boot Camp on my MacBook Pro rather than use VMWare Fusion 3. Overall I've been fine using Windows XP in Fusion for development, but I want to use all 4GB of RAM in the machine rather than just a part and take best advantage of the 64 bit version of Windows 7. It was a resounding failure. I ran into every problem this Gizmodo article talks about. Only difference is that I'm not quite ready to buy a iDefrag quite yet. I probably will, but I think I'll see how things go in the VMWare with the 32 bit version first. If it's sluggish at all, I'll get iDefrag and give Boot Camp another shot. But I have to say I'm really surprised Apple's tools can't handle defragmenting on their own. They should have a Defrag tool in the Utilities folder. Instead their language in KB articles reminds me of when Windows NT came out and Microsoft claimed defragmentation on NTFS wasn't necessary any longer. I didn't believe it, and was proven correct in no time...


About The Author

Ron Grove draws on over ten years of training, network administration and development experience. He loves to work with new technology and see how that technology can be best utilized by his clients. You can find him through his company Evanoah, LLC or through his LinkedIn profile.

Tuesday, November 3, 2009

RemObjects releases Data Abstract for OS X

Downloaded it already and looking forward to playing with the new toy. If you're curious you can find the release notice here:

RemObjects Software introduces Data Abstract for Mac OS X

And of course the DataAbstract product page with a lot more information is here:

DataAbstract for OS X

I finally got an iPhone for Evanoah, LLC (my company) a few weeks ago and have a couple books sitting next to me as I stumble through learning how to develop for it. Looking forward to how I can use this to reach more clients. Sadly it's all still a little on the back burner, though, as I continue working on learning ASP.NET MVC to get my new training website up and running. But as soon as that's done, I'm going to have to make some time for this. Been saying it for months now, but I really want Mac OS X development to become an equal part of what I can offer customers. Time is always an issue isn't it? :-)


About The Author

Ron Grove draws on over ten years of training, network administration and development experience. He loves to work with new technology and see how that technology can be best utilized by his clients. You can find him through his company Evanoah, LLC or through his LinkedIn profile.

Wednesday, October 7, 2009

Windows Mobile 6.5

Well, it's finally time to get a cell phone for my new company. Since I already have a simple (I hope) iPhone app gig lined up I knew what I was going to get, but was looking at other options for my wife. Not sure if she'll want to go with the iPhone or not, we'll see. We both use Macs for everything, but she already has an iPod Touch that she likes. While looking around I happened to notice their new HTC model running Windows Mobile 6.5 and I have to say it's terrible. Better, but still lagging way behind the competition in usability. They've done a lot o work to make it more touch friendly than the old versions, but there's still a lot of work to be done. It's not hard to find screens where the buttons are almost impossible to use for a fat fingered person like me. And there are still other screens in the options that look like they were written back in the Windows 3.1 days. I can't believe Microsoft is having this much trouble providing an outstanding mobile phone OS. Kind of ticks me off because I'd prefer them to do well. I could write apps for that platform since I know their tools well. I don't want to deal with Blackberry, Palm's new WebOS, or Android (which I think uses Java and I don't know Java from adam) but if they don't get off their duffs and deliver on Windows Mobile 7 it may be too late. Then it'll be time to start learning about Android development I suppose...


About The Author

Ron Grove draws on over ten years of training, network administration and development experience. He loves to work with new technology and see how that technology can be best utilized by his clients. You can find him through his company Evanoah, LLC and his LinkedIn profile is here.