TDbf DBGrid on OSX SnowLeopard lazarus / 16-Databases ---------------------------------------------------------------------- oldlibmike · 2011-01-15 20:53 Hi all, I am trying to port an "ancient" dbf based Delphi app to Lazarus. So far I installed TDbf, put a small form together with one table and datasource with a data grid. The grid works and displays data but I am unable to edit the form. The "Autoedit" is set, the table is active and readonly is false. Any ideas what might make the data uneditable in the form? Version 0.931 of Lazarus, 2.3.2 FPC SVN Revision 28816 Code: unit Unit1; {$mode objfpc}{$H+} interface uses   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, DBGrids,   DbCtrls, StdCtrls, dbf, db; type   { TForm1 }   TForm1 = class(TForm)     AHACatCDE_CAT: TSmallintField;     AHACatNAM_CAT: TStringField;     DBGrid1: TDBGrid;     DSAHACat: TDatasource;     AHACat: TDbf;     Edit1: TEdit;     procedure FormActivate(Sender: TObject);   private     { private declarations }   public     { public declarations }   end; var   Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.FormActivate(Sender: TObject); begin   AHACat.Active := true; end; end. ---------------------------------------------------------------------- Phil · 2011-01-15 21:25 Quote from: oldlibmike on January 15, 2011, 09:53:17 pmHi all, I am trying to port an "ancient" dbf based Delphi app to Lazarus. So far I installed TDbf, put a small form together with one table and datasource with a data grid. The grid works and displays data but I am unable to edit the form. The "Autoedit" is set, the table is active and readonly is false. Any ideas what might make the data uneditable in the form? Check to see if the data source is readonly? Thanks. -Phil ---------------------------------------------------------------------- paweld · 2011-01-15 21:27 Check DBGrid options: dgEditing Pozdrawiam / Best regards Paweł Dmitruk ---------------------------------------------------------------------- Phil · 2011-01-15 21:31 Quote from: paweld on January 15, 2011, 10:27:21 pmCheck DBGrid options: dgEditing But that option is set by default both in Delphi and Lazarus, so if his app worked (edited) in Delphi, I would assume that it's set. Thanks. -Phil ---------------------------------------------------------------------- oldlibmike · 2011-01-15 23:42 Thanks for the replies. the TDbf has ReadOnly set to FALSE The DataSource does not have a read only property. The Autoedit is set to true and enabled is true. The DBGrid has the dgEditing set to True. Just to clarify - I am actually planning on rewriting the Delphi app (not converting it) so I am starting with a very simple form with new objects - just to see if it will work as Dbf or if I should convert the data to SQLite3. Thanks for the suggestions though. I can put an edit control in the form and it works. But any DB control won't let me update anything. Could this be a permissions issue on directories or files in OSX? Mike ---------------------------------------------------------------------- Phil · 2011-01-16 00:17 Quote from: oldlibmike on January 16, 2011, 12:42:53 amCould this be a permissions issue on directories or files in OSX? I would guess that it's not a permissions issue. I assume the the data source's DataSet is set to AHACat. Does TDbf have a ReadOnly property? If you have access to a Windows machine, you could copy your project to it and recompile and see if it works there as a way to narrow down the problem. Also, I suppose you could make sure the .dbf table is not read-only. Select it in Finder and press Cmd+I. Then look at the bottom at the "Me" (i.e., you) privileges. It should say read-write. However, even if it's read-only, I don't know that this information would necessarily make its way all the way up to the grid itself. One advantage to Sqlite on Mac is that it's installed on all Macs (/usr/lib/libsqlite3.dylib), as well as on iOS devices (iPhone, iPod touch, iPad). So if you distribute your app to other Mac users, you wouldn't have to worry about installing a support library. (Of course that's probably true with dBase files too since they're so simple - support is probably built into FPC without an external library.) Normally I don't work with TDBGrid in Lazarus or Delphi, but I did port the Delphi FishFacts example to Lazarus last year as a test. There were a number of bugs at that time. I haven't gone back to it since, but I did write up the results: http://web.me.com/macpgmr/ObjP/MacXPlatform_Part6.html Note that since then Juha has really enhanced the Lazarus facility for converting Delphi projects and forms to Lazarus, so that should address one of my concerns. Also, if you're serious about writing, say, production-quality code, you might want to look over this article as well for some ideas: http://web.me.com/macpgmr/ObjP/MacXPlatform_Part8.html Thanks. -Phil ---------------------------------------------------------------------- oldlibmike · 2011-01-16 16:25 Interesting reading! Thanks. I have been looking into other options such as Objective-C but seems like a steep learning curve. Lazarus looks very promising but I am seeing that it is very much in flux it seems. Even using SQLite3, I try updating in the grid and when I leave the cell, it goes blank. I assume I need to put a post somewhere for SQLite3 from what I read - I will play around some more to see if it is usable with SnowLeopard. I can run Windows to test it out but sort of defeats the purpose. I have Delphi 5 for Windows apps - ancient version I know! ---------------------------------------------------------------------- Phil · 2011-01-16 18:05 Quote from: oldlibmike on January 16, 2011, 05:25:07 pmInteresting reading! Thanks. I have been looking into other options such as Objective-C but seems like a steep learning curve. ObjC is an interesting and fairly simple language. It's a derivative of C, not C++. Apple added only a small number of features to it. However, you can do just about the same things with FPC's new Objective Pascal dialect on Mac as you can with ObjC. Here are the steps: - Build FPC 2.5.1 from Subversion (4-line script). The current stable 2.4.2 does not have the ObjP dialect support that you need. - Install the Pascal templates in Xcode. - Use Xcode and Interface Builder for everything, but write your code in ObjP instead of ObjC. There's a MacPascal mailing list. Also, the above applies to iOS development as well as OS X. A little more complicated, but the same tools. Quote from: oldlibmikeLazarus looks very promising but I am seeing that it is very much in flux it seems. Yes, it's a volunteer project, with no big corporate sponsors the way most successful open source projects have (think Linux). Take browsers for example: Firefox depends entirely on Google handouts. And Chrome and all mobile browser use the WebKit framework that Apple made available as open source. That's what successful open source on a big scale really means: corporate backing. Quote from: oldlibmikeEven using SQLite3, I try updating in the grid and when I leave the cell, it goes blank. I assume I need to put a post somewhere for SQLite3 from what I read - I will play around some more to see if it is usable with SnowLeopard. Your problems probably are not related to Snow Leopard, but rather to some issue with the grid maybe. If you can isolate and identify the problem, please post a bug report (see Bugtracker at left). I ported the Orpheus TOvcTable to Lazarus and you could try that on OS X, but I never got it working as well as on Windows. TDbGrid is kind of deprecated in the Delphi world, I would guess. Quote from: oldlibmikeI can run Windows to test it out but sort of defeats the purpose. I have Delphi 5 for Windows apps - ancient version I know! Well, the idea is to eliminate possible problem areas. If you have the same problem on Windows with Lazarus, then it's probably not a widgetset issue, but something higher up, etc.