sqlite newbie question lazarus / 16-Databases ---------------------------------------------------------------------- Pascaluvr · 2012-03-28 08:17 Hi all, my entry into another area is frustrating me. For years I have used my own Database system and I have resisted SQL the way I resisted OOP. Now I wish to try SQL using sqlite.  My choice for sqlite is simple - I want a single user database without the overheads of multiuser systems. my requirements are simple: 1) if the Database / table doesn't exist, I will create it within the program. 2) Only wish to return one result at a time. Now this should be easy, but most sample programs on the net assume an existing DB.  Those that show the definition of a DB are stand alone examples.  I really need for my program to create the DB and Tables if they don't already exist. Searches on the web have been frustrating to say the least - but then, whats new? I have found 'Lazarus components' that I can supposedly install by clicking IDE-->Components HUH - where is the 'Components' menu option. I also found that I can just add a Sql3Connect onto my form, right click, and click 'edit database' ...  be nice if this option actually existed, but even so, it sort of implies that I would need to define the DB outside of my program - so still not what I want. Anyone got a starting point for me please? ---------------------------------------------------------------------- Arbee · 2012-03-28 09:50 As far as creating a new database is concerned .... IIRC in SQLITE a database is created automatically if you connect to it and it does not yet exist. Of course you would want to know if it does (so that you also know if you first need to create the tables).  I don't think SQLITE itself has something for that, but a database is just another file so you can just check if a file with that name exists or not and then act accordingly after the connect. ---------------------------------------------------------------------- sfeinst · 2012-03-28 11:35 I haven't done a lot with sqlite but I did put together a basic test app to try some things out.  There may be mistakes or unneeded code, but it ran and I think it is a starting point.  I know you want it all in code, but my example uses 3 controls from the sqldb tab in the IDE on the form.  It is possible to instantiate the objects instead, but for testing purposes I just wanted something quick.  I do not check for file exists to determine if I should create a database, I just have a procedure to do it.  But if you wanted that feature, just use the basic file commands in pascal to check the existence of the file. Hope it helps ---------------------------------------------------------------------- garlar27 · 2012-03-28 12:06 Check this: To get a Table names' list: TSQLite3Connection.GetTableNames(List : TStrings; SystemTables : Boolean = false); If you need to create a Table in the DB: TSQLite3Connection.ExecuteDirect(SQL: string); Code: [Select]SQLite3Connection1.ExecuteDirect('CREATE TABLE "MY_TABLE"("UUID" NVARCHAR(36), "NAME" NVARCHAR(50), CONSTRAINT PK_MY_TABLE" PRIMARY KRY ("UUID" ASC));'); Go to http://www.sqlite.org/ to learn about the uniqueness of SQLite and it's weird type handling. QuoteHUH - where is the 'Components' menu option.I don't know the English name but I think it should be "Package" between "Run" and "Tools" You can also try ZEOS DBO components. I use it a lot ---------------------------------------------------------------------- Pascaluvr · 2012-03-28 15:17 WOW!!!!!  Thank you all for the truly great replies  Everyone has been extremely helpful sfeinst:  Your test program was exactly the starting point I needed, doing just enough to get me started, and not too much to totally confuse me A couple of side issues: 1) In project1.lpr there is a statement:   RequireDerivedFormResource := True;    Which is an unknown variable name when I compile.  I just commented this out and it was fine.  I came across this on a sample program someone else supplied me too.  I am guessing this maybe a platform specific issue.  (I have Windows XP, Laz ver: 0.9.30.2, FPC 2.4.4) I am wondering if it should be reported as a bug, maybe needing something like {IFDEF UNIX} 2) I also had a problem with the statement: msg := msg + {sqlQuery.FieldDefs[index].Name + ': ' +} sqlQuery.Fields[index].AsString; Notice I commented out the sqlFieldDefs code.  This doesn't exist on my version.  Again, no big deal. 3)  I notice that for each button click you sqlConn.Open and Finally sqlConn.Close I assume you did this to make each button standalone.  In a real application the connection would normally be Open for the duration - is this correct? Thanks again for all the great responses ---------------------------------------------------------------------- sfeinst · 2012-03-28 17:00 Glad it is helping. 1) I did not add this code, so most likely a version thing, not a bug.  I am running Windows 7, Lazarus 0.9.31 and FPC 2.6. 2) Might be a version thing as well.  I might also have added packages to Lazarus (I can't remember if they were installed by default or added them a while ago).  If I added them, then they are part of Lazarus and just not added by default.  If they were there, then a version thing.  But check your install to see if you have SQLDBLaz.  But I do lean towards version being different. 3) I open/close for each button because I am used to writing multi- user databases and having an open connection sitting around is not good programming practice (Actually in those apps - Java not Pascal and not sqlite - I tend to use a connection pools). I also like to keep connections closed with local DBs the same way I don't leave files open.  I haven't delved into sqlite code to see if it opens the file on connections, but I prefer to be safe in case of app crashes.  I also tend to code assuming my backend may change. So it is possible to have one connection that you reuse.  Maybe others have an opinion after having used sqlite for a while. Also, throwing in this link which has some good basic database/data- aware info related to Lazarus (I originally stole this code when building that test): http://wiki.lazarus.freepascal.org/Databases ---------------------------------------------------------------------- garlar27 · 2012-03-28 17:53 Quote from: sfeinst on March 28, 2012, 07:00:32 pm... I also like to keep connections closed with local DBs the same way I don't leave files open.  I haven't delved into sqlite code to see if it opens the file on connections, but I prefer to be safe in case of app crashes.  ... ... Although SQLite web Page says: QuoteSQLite is Transactional A transactional database is one in which all changes and queries appear to be Atomic, Consistent, Isolated, and Durable (ACID). SQLite implements serializable transactions that are atomic, consistent, isolated, and durable, even if the transaction is interrupted by a program crash, an operating system crash, or a power failure to the computer. We here restate and amplify the previous sentence for emphasis: All changes within a single transaction in SQLite either occur completely or not at all, even if the act of writing the change out to the disk is interrupted by     a program crash,     an operating system crash, or     a power failure. The claim of the previous paragraph is extensively checked in the SQLite regression test suite using a special test harness that simulates the effects on a database file of operating system crashes and power failures. Being a little paranoid it's not a bad idea (except if the connection overhead is a problem). ---------------------------------------------------------------------- sfeinst · 2012-03-28 18:02 I tend to program maintainable/safe first and then refactor if speed is an issue, but good to know this is an option.  Thanks for the sqlite link as well. ---------------------------------------------------------------------- Pascaluvr · 2012-03-28 21:36 Thanks sfeinst. Maybe I should upgrade. Thanks for those links I have found some good stuff in there, but I'm sure I will have more questions as I go along ---------------------------------------------------------------------- LuizAmérico · 2012-03-29 00:07 Quote1) if the Database / table doesn't exist, I will create it within the program. You may have a look at http://sqlite4fpc.yolasite.com/documentation.php mainly Tutorial 01 It uses TSqlite3Dataset that can be used even without knowledge of SQL (see other tutorials) ---------------------------------------------------------------------- Pascaluvr · 2012-03-29 05:26 hi Luiz, and thanks for that. I found just the command I need: 'Create Table if not exists MyTable (id autoinc primary key, data text, .................... )' I have to admit I was very skeptical about SQL - yet another place to define the same data - but it seems to be falling into place. Regards ---------------------------------------------------------------------- BigChimp · 2012-03-29 07:43 "yet another place to define the same data" is exactly the thing one would hope to avoid in a properly normalized database though Kidding aside, I would suggest you upgrade your Lazarus/FPC install to e.g. the recently released 0.9.30.4 (IIRC) with FPC 2.6 There've been a lot of improvements since the previous version was released (IIRC a year ago). I'm running the latest Lazarus (trunk from the SVN repository) myself, with fixes 2.6 (FPC 2.6 with backported fixes from trunk/2.7.1). Works fine. Also, if you want to be totally safe, you can use 2 or more separate instances of FPC and Lazarus by saving them in different directories and starting the "new" Lazarus with a different primary-config-path (--pcp= or --primary-config-path is... This is what e.g. my fpcup installer/updater does for you. On the other hand, I can imagine you want to avoid some complexity while learning a new environment. In that case, I'd still propose you upgrade Lazarus/FPC... ---------------------------------------------------------------------- Pascaluvr · 2012-03-29 09:53 Hi BigChimp, I have upgraded now and its fixed a couple of issues I had with sfeinst's sample he kindly uploaded for me You are correct though.  When I'm learning something new, or working on a project, downloading a new version is just another complication (unless its fixing a problem I'm having). I can't believe it tho.  SQL is really growing on me.  I have resisted OOP and SQL for so many years (and to be honest, I can still live without OOP - pointers don't scare me and having a ^ in a field reference doesn't  intimidate me in the slightest) but every new little thing I learn about SQL just inspires me more. (Not bad for a 64 year old that resists change Thanks for your help and encouragement - I'm sure I will be bugging this forum with more newbie issues as I continue. ---------------------------------------------------------------------- BigChimp · 2012-03-29 13:33 Glad to hear it. People that actually provide not only negative but also positive feedback are a refreshing departure from the norm And yes, it took a while for SQL/RDBMS to sink in with me too, but after that I was sold... Had my own programming roots in procedural programming and OOP still is something that doesn't always come naturally to me. Fortunately I'm only a hobby programmer ... and FPC allows you to use procedural and OOP in the same program. As for resisting change: yes, very familiar. One does tend to get a bit set in one's ways Regards, BigChimp ---------------------------------------------------------------------- Pascaluvr · 2012-04-01 07:29 Quote from: BigChimp on March 29, 2012, 03:33:58 pm Glad to hear it. People that actually provide not only negative but also positive feedback are a refreshing departure from the norm And yes, it took a while for SQL/RDBMS to sink in with me too, but after that I was sold... Had my own programming roots in procedural programming and OOP still is something that doesn't always come naturally to me. Fortunately I'm only a hobby programmer ... and FPC allows you to use procedural and OOP in the same program. As for resisting change: yes, very familiar. One does tend to get a bit set in one's ways Regards, BigChimp From what I see, OOP is great for an application like Lazarus, but if you have a single instance of an object in an application - why the hell bother? To write in OOP for such simple applications just reminds me of Computer Science graduates, that have no real world experience, telling the world how to program, based on the theories of a lecturer who has never been in the real world either. Best regards - and no offense meant to computer science graduates = just get some experience in the real world. ---------------------------------------------------------------------- BigChimp · 2012-04-01 08:12 Seems like it... until you start chopping up your program into smaller objects. The promise of object reuse does sound a bit hollow though, when dealing with smaller programs. Myself, I like OOP because it allows me to forget how parts of the cod work internally as long as I can manipulate the object (sensible property/method names are especially important then). Agreed about real world being different from the academic world ---------------------------------------------------------------------- Pascaluvr · 2012-04-01 08:43 Quote from: BigChimp on April 01, 2012, 10:12:54 amSeems like it... until you start chopping up your program into smaller objects. The promise of object reuse does sound a bit hollow though, when dealing with smaller programs. Myself, I like OOP because it allows me to forget how parts of the cod work internally as long as I can manipulate the object (sensible property/method names are especially important then). Agreed about real world being different from the academic world Interesting BigChimp There is no doubt that a product like Lazarus could not be developed without OOP = errr will it could be, just be a hell of a lot harder. For example, I wrote an ISAM file management system without OOP.  I used pointers. Because it was for me = no big deal. In fact, the only major difference between an OOP thang and mine, was I used pointers.  Anyone with half a brain can see that OOP is just pointers without the ^ in the name. Way back before OOP. it was easy, just put Public stuff before IMPLEMENTATION, and private stuff after it.  Initialization was simple... just put that before the last .end; Clearly, in a Database program, I needed multiple instances, but no big deal, I just had a linked list of pointers.  I have no doubt that OOP comes into its own when there are an unknown number of multiple instances on a form, but reality is, we can all program that too. If you aren't scared of pointers, you can program your own OOP when you wish. ---------------------------------------------------------------------- BigChimp · 2012-04-01 08:54 QuoteIf you aren't scared of pointers, you can program your own OOP when you wish. Yep, OOP=pointers, functions etc. It's basically nothing new, but a bit easier for newbies/careless people like me to use. I played enough with pointers to know they and I don't get along.... and it's not their fault ---------------------------------------------------------------------- Pascaluvr · 2012-04-01 09:03 Quote from: BigChimp on April 01, 2012, 10:54:50 amQuoteIf you aren't scared of pointers, you can program your own OOP when you wish. Yep, OOP=pointers, functions etc. It's basically nothing new, but a bit easier for newbies/careless people like me to use. I played enough with pointers to know they and I don't get along.... and it's not their fault ROFLMAO .... its really funny, because Pointers and I get along far better than Objects: ---------------------------------------------------------------------- chrnobel · 2012-04-05 20:48 Quote from: BigChimp on April 01, 2012, 10:54:50 amYep, OOP=pointers, functions etc. How can you say OOP equals pointers? I agree that one could say that OOP is similar to a fancy use of procedures and functions, where the procedures and functions can be saved as objects and be eventdriven, but pointers - no. Imo pointers are just a way of making ones life more complicated instead of using the powerful array facilities in FPC (and I am totally aware of that there resides pointers in the backstage, but I don't have to mess with them), and thus avoiding making stupid memory crashes. Just my 5 cents ---------------------------------------------------------------------- garlar27 · 2012-04-05 21:27 Quote from: Pascaluvr on April 01, 2012, 11:03:21 amROFLMAO .... its really funny, because Pointers and I get along far better than Objects: Quote from: chrnobel on April 05, 2012, 10:48:59 pmImo pointers are just a way of making ones life more complicated instead of using the powerful array facilities in FPC (and I am totally aware of that there resides pointers in the backstage, but I don't have to mess with them), and thus avoiding making stupid memory crashes. I'm sorry but, I don't understand why are you complaining (about Objects for some people and Pointers to others). When you must to take care of the same things:    1. CREATE YOUR OBJECT/POINTER BEFORE USE IT.    2. MAKE SURE IT IS ASSIGNED BEFORE USE IT.    3. RELEASE IT FROM MEMORY WHEN IT'S NO LONGER NEEDED.    4. NOT TO LOSE REFERENCE OF YOUR OBJECT/POINTER BEFORE IT IS RELEASED FROM MEMORY. ---------------------------------------------------------------------- ludob · 2012-04-06 07:07 Code: [Select]   1. CREATE YOUR OBJECT/POINTER BEFORE USE IT.    2. MAKE SURE IT IS ASSIGNED BEFORE USE IT.    3. RELEASE IT FROM MEMORY WHEN IT'S NO LONGER NEEDED.    4. NOT TO LOSE REFERENCE OF YOUR OBJECT/POINTER BEFORE IT IS RELEASED FROM MEMORY. You seem to forget one important thing: with pointers you can do anything, including shooting in your foot. A strictly typed language does everything to avoid that. Most of the pointer problems are not linked to the 4 steps you list but to wrong casting, out of range pointers, wrong number of indirections (pointer vs value pointed to), memory alignment problems on some cpu's requiring aligned memory access, etc. ---------------------------------------------------------------------- Pascaluvr · 2012-04-06 08:33 Quote from: ludob on April 06, 2012, 09:07:16 amCode: [Select]   1. CREATE YOUR OBJECT/POINTER BEFORE USE IT.    2. MAKE SURE IT IS ASSIGNED BEFORE USE IT.    3. RELEASE IT FROM MEMORY WHEN IT'S NO LONGER NEEDED.    4. NOT TO LOSE REFERENCE OF YOUR OBJECT/POINTER BEFORE IT IS RELEASED FROM MEMORY. You seem to forget one important thing: with pointers you can do anything, including shooting in your foot. A strictly typed language does everything to avoid that. Most of the pointer problems are not linked to the 4 steps you list but to wrong casting, out of range pointers, wrong number of indirections (pointer vs value pointed to), memory alignment problems on some cpu's requiring aligned memory access, etc. I totally disagree. With objects you can totally shoot yourself in the foot also.  And get exactly the same problems. I don't want to argue, but it seems some people are more comfortable when there isn't a ^ in a field name, but expound the virtues of a technique that hides the ^ from you.  Being an ex-assembler programmer also, I can see how it works, but I prefer the 'honesty' of declaring something as a pointer when I use one. While I am far from an OOP convert, in fact, still a OOP negative, I can see the advantages in using OOP for an unknown number of instances (although I don't really need OOP to handle it, I can manage that fine myself ) Lazarus is an excellent example of successfully using OOP.  Forms Design is exceptional.  But why do people use OOP for a single instance?  Why do people code in OOP just because its there?  Why do people make their code more more complicated to read when a simple single instance procedure would have sufficed? What I don't understand is why people code in OOP when there is no need.  For example, for one instance, but we create an object????  A simple FPC Record would have created a static variable without all the overhead of an object!!!! ---------------------------------------------------------------------- ludob · 2012-04-06 08:57 QuoteWith objects you can totally shoot yourself in the foot also.  And get exactly the same problems. Can you give an example using objects that results in any of the pointer errors/problems I listed ? An example that doesn't use pointers, @ operators or casting to untyped parameters. QuoteWhat I don't understand is why people code in OOP when there is no need.  For example, for one instance, but we create an object????  A simple FPC Record would have created a static variable without all the overhead of an object!!!!I'm not an OOP aficionado either. My background is also assembler and C. But I do create classes when there is a high chance I need to re-use the code in another project and when a certain degree of abstraction is needed. And yes , code re-use, abstraction and multiple instances can also be obtained with pointers and records, but in a few months time I have forgotten the inner workings and I'll have to re-read that code again to figure out how it all worked while classes have an interface and a usage that is far more standardised. ---------------------------------------------------------------------- Pascaluvr · 2012-04-06 09:07 Quote from: ludob on April 06, 2012, 10:57:25 amQuoteWith objects you can totally shoot yourself in the foot also.  And get exactly the same problems. Can you give an example using objects that results in any of the pointer errors/problems I listed ? An example that doesn't use pointers, @ operators or casting to untyped parameters. [?quote] You are kidding me right?  You have never had problems with an OOP program, but have had them with a non-OOP program.  You have never had a SIDSEGV with an OOP program but you have had had them with a non-OOP program?  Congratulations, you are the only person I know of that achieved this, you go into the hall of fame for non-SIGSEGV reservers. QuoteWhat I don't understand is why people code in OOP when there is no need.  For example, for one instance, but we create an object????  A simple FPC Record would have created a static variable without all the overhead of an object!!!!I'm not an OOP aficionado either. My background is also assembler and C. But I do create classes when there is a high chance I need to re-use the code in another project and when a certain degree of abstraction is needed. And yes , code re-use, abstraction and multiple instances can also be obtained with pointers and records, but in a few months time I have forgotten the inner workings and I'll have to re-read that code again to figure out how it all worked while classes have an interface and a usage that is far more standardised. ---------------------------------------------------------------------- Pascaluvr · 2012-04-06 09:21 Its very simple: Put a comment at the start of the procedure explain what is does.  Why is this not necessary in OOP components?  Is OOP more self = documenting?  I haven't seen that side of it. ---------------------------------------------------------------------- Pascaluvr · 2012-04-06 09:35 Quote from: ludob on April 06, 2012, 10:57:25 amQuoteWith objects you can totally shoot yourself in the foot also.  And get exactly the same problems. Can you give an example using objects that results in any of the pointer errors/problems I listed ? An example that doesn't use pointers, @ operators or casting to untyped parameters. I wish I could, but as you know, most people go thru several iterations of heartbreak before they find the solution. ---------------------------------------------------------------------- ludob · 2012-04-06 09:49 QuoteYou are kidding me right?  You have never had problems with an OOP program, but have had them with a non-OOP program.  You have never had a SIDSEGV with an OOP program but you have had had them with a non-OOP program?  Congratulations, you are the only person I know of that achieved this, you go into the hall of fame for non-SIGSEGV reservers.I have seen my part of SIGSEGV, even with OOP programs, don't worry But they all boil down to the use of non instantiated classes, range errors in arrays or ... the use of pointers. Did I say OOP was the solution to get rid SIGSEGV? Bad programming isn't getting any better using objects. The only thing I'm saying is that when using pointers you don't have any of the compiler checks strict typing is giving you. You can assign a 10k block to an integer with pointers. Try doing that in pascal without deliberate cheating on the compiler (cast to untyped parameters, use of pointers and @). QuoteIts very simple: Put a comment at the start of the procedure explain what is does.  Why is this not necessary in OOP components? Is OOP more self = documenting?  I haven't seen that side of it. Seems we don't understand each other. I'll  repeat: QuoteAnd yes , code re-use, abstraction and multiple instances can also be obtained with pointers and records, but in a few months time I have forgotten the inner workings and I'll have to re-read that code again to figure out how it all worked while classes have an interface and a usage that is far more standardised.I don't have to document how to instantiate or destroy a class. That is standard. When doing this with records and pointers, there are hundreds of ways of doing the same. Unless you have your own standard way of doing this, you'll need to document the instantiation and destruction of your "pseudo objects".  Of course, class methods and properties have the same documentation needs. Don't put words in my mouth that I haven't said ---------------------------------------------------------------------- BigChimp · 2012-04-06 09:55 Quote from: Pascaluvr on April 06, 2012, 11:21:57 amIs OOP more self = documenting?  I haven't seen that side of it. Yes, I have. Perhaps you should let OOP grow on you a bit... Remember your stance on SQL and how you see it now... having to learn a new way of doing things will highlight the problems in the beginning; only later on will you probably be able to properly compare the old and new way of working. Regards, BigChimp ---------------------------------------------------------------------- Pascaluvr · 2012-04-06 12:42 Quote from: BigChimp on April 06, 2012, 11:55:45 amQuote from: Pascaluvr on April 06, 2012, 11:21:57 amIs OOP more self = documenting?  I haven't seen that side of it. Yes, I have. Perhaps you should let OOP grow on you a bit... Remember your stance on SQL and how you see it now... having to learn a new way of doing things will highlight the problems in the beginning; only later on will you probably be able to properly compare the old and new way of working. Regards, BigChimp Big Chimp, Please don't take offense, I truly enjoy our discussions as they go more to the philosophical and away from the problem at hand. My first introduction to OOP was with Turbo Pascal 5.5.  I truly couldn't see the point.  All it did was enforce a coding standard which I already used a variation of and achieved the same with my pointers.  I had my standard Init and Close blocks, just the way OOP imposes them.  The problem is that to use someone else's object, you need documentation, and that documentation is clearly lacking in the many objects available in FPC/Lazarus.  Maybe if I had a background in Delphi, more of this would be apparent to me, but I don't, so I am working more on 'programmers intuition' than a knowledge base.  I can see the benefits of OOP when developing an application using Lazarus, there is no doubt that OOP contributed greatly to what has been achieved.  But you and I ( well I at least) don't develop applications like Lazarus.  I develop applications (as a hobby, and to keep this aging brain ticking over)  that work on a single instance of data.  I don't have the need to build objects and collections of data, or when I do, a simple array of record handles all my needs.  My biggest problem with OOP is that the new kids on the block code this way because that is what they learned in computer science class, and do so even when OOP style gives absolutely no benefit to their program in any way.  Why do people insist on using something just because its there, rather than using something because there is benefit - or is it because they don't know any other way? SQL I have seen in a extremely different light.  It is extremely cumbersome to move data to and from the database to/from the program (instead of just retrieving  a record from a file), but after getting over that PITA, the flexibility is amazing and is probably worth the pains involved.  Again though, documentation is sadly lacking, because it either assumes you are a computer science graduate and already know the theory, or that you are a complete novice and don't give you enough other than complete raw basics.  Thanks to the help of people like you I am learning that intermediate stage and I truly appreciate your patience when I clearly am making a complete idiot of myself.  I can see how OOP and SQL would work hand-in-hand extremely well, but the majority of the programs in the real world don't really need that cooperation.  Unless things have changed since I have been away from programming professionally, programs are more about dealing with an individual transaction.  Its wonderful to be able to request  complex queries against the database (i've had fun playing with it) but reality is, except for specific applications, of little or no use. Thank you again for all your assistance, and thanks for listening to the ramblings of an oldie ---------------------------------------------------------------------- BigChimp · 2012-04-06 13:12 No offence taken at all. I understand your point. As usually, it all depends. To me, the fact that there is such a clear separation between public properties/methods and private code is great. Not being a pointer fan also adds to the appeal. Finally, though I learned procedural programming, object oriented programming was a hype when I got stuck in to more serious programs, I tried it... and it has served me well across a couple of languages. Yes, I probably use it when another solution would be more elegant... but I'm just used to it*) and get my stuff done in the end (and it turns out that I actually do reuse my objects but more importantly other peoples'). *) was starting to begin about memory consumption and CPU cycles not being that tight as they used to be but that's a whole different argument - bloated code is still bloated code. So it also boils down to one's experience. If you have any comments/hints/tips on the wiki documentation, please feel free to edit the wiki pages- even if you only add Huh? What does blablabla mean on the talk page (or here on a forum post). I'm certainly still learning but I very much hate to figure out things, not use them for a while (I'm a hobby programmer, like you) and then have to relearn it. That, coupled with other people complaining about documentation and me figuring out I'm starting to know enough to help people, make me dangerous enough.. I mean... promoted my interest in adding to the existing wiki documentation. The FPC documentation is okish for me but the policy is that only entire unit documentation gets in. Lazarus does not have this policy and has an extremely fragmented documentation... as well as people adopting the wiki as a more fluid, fairly effective but still chaotic means of documenting. Also, at least some FPC people see a big distinction between the formal description of what a feature does and a description of a feature with sample snippets so people not familiar with the concepts don't face a large hurdle. I personnally would like to see both in the documentation. There are always a lot of dicussions on documentation on the FPC & Lazarus mailing lists. Current documentation/doc tools maintainers have seen so many of these come and go without changing things for the better; I think that they are therefore very skeptical of changes. Lately, I think one of them was going to set up a web site that would allow easier editing of the FPC/Lazarus official documentation... if that works, that would already be a big step forward. Also, the way the documentation is generated will probably be easier. Unfortunately, the documentation is kept separate from the source code in xml files. One of those holy war things - myself, I like documentation to be in the code so it is easier to modify, it works as code comments as well, and you can more easily (try to) force people to submit new contributions only if it is properly documented. Well, the FPC (and Lazarus) guys decided otherwise... which is fine by me: a decision is better than no decision. Anyway, I think I've rambled enough myself Regards, BigChimp ---------------------------------------------------------------------- chrnobel · 2012-04-06 18:12 Quote from: Pascaluvr on April 06, 2012, 02:42:16 pmSQL I have seen in a extremely different light.  It is extremely cumbersome to move data to and from the database to/from the program (instead of just retrieving  a record from a file), but after getting over that PITA, the flexibility is amazing and is probably worth the pains involved.  Again though, documentation is sadly lacking, because it either assumes you are a computer science graduate and already know the theory, or that you are a complete novice and don't give you enough other than complete raw basics. You have to look at the "SQL problem" from two angles: 1. Getting the connection and retrieving data from the SQL database (which in fact can be any SQL database, be it MySQL, SQLite, Firebird, PostGress, etc - the beauty is, if you can do it with one, it is very easy growing to another) which can be a bit cumbersome until one have cracked the nut, but when this is done, access to any SQL database can be done very, very fast with Lazarus, and it takes very little time to make a fullblown database application, thanks to all the database components in Lazarus. 2. Using SQL as such - there is tons of documentation on how to use SQL (which can be very powerfull) on the internet, especially I can recommend this: http://www.w3schools.com/sql/default.asp IMO SQL is one of the best inventions after sliced toast, and the way it can be used, and the way one can manipulate the resultset, based on very few commands, is impressive. ---------------------------------------------------------------------- garlar27 · 2012-04-09 16:48 Objects, Pointers and why should I point to my foot with a loaded gun with it's safety off and my finger on the trigger? Objects or pointer? That's the question!    The other day I needed to pass data through many modules. So I built a record and a pointer to it since data would be processed in the same object where data was generated (if I don't need a class I don't use it). But later I realized that data needs some extra processing in many modules. This would need to have scattered data handling in many different modules which is not a god idea. Thus the record and it's pointer where not enough!    So I redefined "TMyData" as "Class(TObject)" instead of "record" and problem solved. Now I send Objects instead of pointers. And now I'm changing the TFPList to a TCollection descendant and TMyData to a TCollectionItem descendant. This way I avoid to reinvent the wheel since the wheels that already exist fit the project's needs. Safety First!!    If any of you need to do something that is "not totally safe" and there's no other way. You better do it in a very controlled way and in a punctual place and with as many precautions as possible. So if you need to point down with your gun then don't aim to your foot (is better to point to the air) or move your foot from that place!! Sorry for shaking the hive. ---------------------------------------------------------------------- Pascaluvr · 2012-04-10 08:49 Quote from: garlar27 on April 09, 2012, 06:48:38 pmObjects, Pointers and why should I point to my foot with a loaded gun with it's safety off and my finger on the trigger? Objects or pointer? That's the question!    The other day I needed to pass data through many modules. So I built a record and a pointer to it since data would be processed in the same object where data was generated (if I don't need a class I don't use it). But later I realized that data needs some extra processing in many modules. This would need to have scattered data handling in many different modules which is not a god idea. Thus the record and it's pointer where not enough!    So I redefined "TMyData" as "Class(TObject)" instead of "record" and problem solved. Now I send Objects instead of pointers. And now I'm changing the TFPList to a TCollection descendant and TMyData to a TCollectionItem descendant. This way I avoid to reinvent the wheel since the wheels that already exist fit the project's needs. Safety First!!    If any of you need to do something that is "not totally safe" and there's no other way. You better do it in a very controlled way and in a punctual place and with as many precautions as possible. So if you need to point down with your gun then don't aim to your foot (is better to point to the air) or move your foot from that place!! Sorry for shaking the hive. General Response: I truly thank everyone for their comments, opinions and advice.  If it ever appears here that I seem to be disagreeing with a far more experienced programmer than myself, it is probably because I worded it badly, and was just asking for clarification. Specific Response: Garlar27 I understand and see your point.  I also understand how OOP helps in this area above procedural programming, because it enforces a stricter coding standard.  But, with all due respect, that still doesn't mean that an OOP programmer will have less errors than a older structural programmer.  Using my 'old world' techniques, for record handling that was more complex than the straight forward, I (probably) used OOP techniques without really realising it: 1:  I had a Unit to specifically handle the Record manipulation 2:  I had Public  and Private Routines - easy, Public were declared as a Forward declaration before IMPLEMENTATION, Private were declared after. 3:  There was usually a Open/Init function and a corresponding Close function. Please don't get me wrong, I really understand that OOP can be very beneficial in some circumstances, I just don't understand why some people use it even when its not necessary.  To attempt to read their code and (in the back of the mind - this must be an Object for a reason) soon just turns a simple example into unnecessary complexity. I do like the power of OOP, but when there are only singular instances of data (quite common in many programs), I can't understand why people insist on using OOP when FPC quite happily allows you to mix the two. As an oldie, I truly enjoy learning new stuff ...  it keeps the old gray cells  active, but also as an oldie, I will only use new stuff because it is helpful - not just because its there! Best regards and thanks for the response ---------------------------------------------------------------------- garlar27 · 2012-04-10 13:11 I think you get me wrong. English is not my language and some times I can't express my self right.    None is forced to use objects, in fact, half of my "toolbox" are procedure and functions and the other half classes (some small and some are big).    I started programing in august 1991. One year later I started with TP 6 and I enjoy using pointers specially in double chained list (I think FPC and Lazarus do not use them much) and I don't understand why many people dislike the use of pointers.