Recent

Author Topic: Health Daily Monitor (updated links)  (Read 17292 times)

minesadorada

  • Sr. Member
  • ****
  • Posts: 452
  • Retired
Health Daily Monitor (updated links)
« on: July 24, 2014, 12:19:53 pm »
I bought one of those Blood Pressure machines last year - now I'm older I need to keep an eye on my health.  It displays blood pressure and pulse, with an inbuilt 'memory' for the last 10 readings or so.  Being an ex-programmer I naturally thought of writing a Lazarus app to keep a record of readings, and displaying stats, graphs etc - which I did, but it was very much a 'quick-and-dirty' effort.

Recently I decided to do it 'properly' via a searchable database.  I have never used Lazarus directly with a database before, so all the DB stuff has been a good learning experience.  The Wiki was invaluable.  All the database interactions are in a seperate  class.

The result so far is 'Health Daily Monitor' (Sourceforge Project Page)

Windows 32-bit Installers are in the project page [Files] section

Databases supported
  • MSaccess
  • SQLite 3
  • Firebird embedded (thanks BigChimp)
  • MySQL 5.6 server

The app simply stores the records, and provides some simple stats along with basic User and Record management.  A follow-up app will use the db to display graphs (another leaning experience to come!)

I must thank users howardpc and wp here for the CalendarLite code.  It is a neat solution for my app - I populated the 'Holidays' with valid record days, so the user can simply click on a highlighted day to edit a record.  Also, thank you to user BigChimp for implementing Firebird functionality

It's a really simple app, but as the title says; it's my first foray into Lazarus DB programming.  It's a 'hobby' project - LGPLv2 etc.  The different databases made it more interesting.

Note The MSaccess Edition needs MSAccess DB drivers installed on your system.  Download free AccessDatabaseEngine available here:  Microsoft Download Link if you haven't got them already.
« Last Edit: July 27, 2014, 06:28:00 pm by minesadorada »
GPL Apps: Health MonitorRetro Ski Run
OnlinePackageManager Components: LazAutoUpdate, LongTimer, PoweredBy, ScrollText, PlaySound, CryptINI

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Health Daily Monitor - my first foray into Lazarus DB programming
« Reply #1 on: July 24, 2014, 12:42:52 pm »
Hi minesadorada,

Great, thanks for publishing! I'm assuming you're welcoming critic^H^H^H advice for improvement as you're still learning?

Being a Windows MSAccess app, it needs MSAccess DB drivers installed on your system.  Download free AccessDatabaseEngine available here:  http://www.microsoft.com/en-us/download/details.aspx?id=132 if you haven't got them already.
Hmmm.. that link shows a page titled Microsoft .NET Framework 3.5 Service Pack 1 and .NET Framework 2.0 Service Pack 2 Security Update for Windows 2000, Windows Server 2003, and Windows XP for me. Are you sure that's the right one?
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

minesadorada

  • Sr. Member
  • ****
  • Posts: 452
  • Retired
Re: Health Daily Monitor - my first foray into Lazarus DB programming
« Reply #2 on: July 24, 2014, 12:48:50 pm »
...
Hmmm.. that link shows a page titled Microsoft .NET Framework 3.5 Service Pack 1 and .NET Framework 2.0 Service Pack 2 Security Update for Windows 2000, Windows Server 2003, and Windows XP for me. Are you sure that's the right one?

Sorry - I've corrected the link in the post. It's http://www.microsoft.com/en-us/download/details.aspx?id=13255

I'm up for any criticism or better still - free advice.  Why else would I post here :)
GPL Apps: Health MonitorRetro Ski Run
OnlinePackageManager Components: LazAutoUpdate, LongTimer, PoweredBy, ScrollText, PlaySound, CryptINI

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Health Daily Monitor - my first foray into Lazarus DB programming
« Reply #3 on: July 24, 2014, 01:10:02 pm »
I have a CreateProcess error, either running the app from the IDE or from the OS (Windows 32).

Rails

  • Guest
Re: Health Daily Monitor - my first foray into Lazarus DB programming
« Reply #4 on: July 24, 2014, 01:22:32 pm »

I'm up for any criticism or better still - free advice.  Why else would I post here :)

Hmmm, license.   :D

It just so happens I could use that application, if it weren't using Access. Since Laz is cross platform, why not use a cross platform database instead? That should give you a broader user base.

minesadorada

  • Sr. Member
  • ****
  • Posts: 452
  • Retired
Re: Health Daily Monitor - my first foray into Lazarus DB programming
« Reply #5 on: July 24, 2014, 01:24:12 pm »
I have a CreateProcess error, either running the app from the IDE or from the OS (Windows 32).

I have no idea where that bug could come from?  Could you perhaps look at the source and find out?

Development environment is in my sig.
« Last Edit: July 24, 2014, 01:29:38 pm by minesadorada »
GPL Apps: Health MonitorRetro Ski Run
OnlinePackageManager Components: LazAutoUpdate, LongTimer, PoweredBy, ScrollText, PlaySound, CryptINI

minesadorada

  • Sr. Member
  • ****
  • Posts: 452
  • Retired
Re: Health Daily Monitor - my first foray into Lazarus DB programming
« Reply #6 on: July 24, 2014, 01:25:46 pm »

I'm up for any criticism or better still - free advice.  Why else would I post here :)

Hmmm, license.   :D

It just so happens I could use that application, if it weren't using Access. Since Laz is cross platform, why not use a cross platform database instead? That should give you a broader user base.

All the database actions are encapsulated in a class.  In theory it could be subclassed to use an Open Source database without affecting the GUI.

I used Access because it was convenient - no other reason.  I think the SQL and table structures are simple and generic, so subclassing wouldn't be complicated.

I assumed that using the free re-distributable AccessDatabaseEngine didn't require a license for the user.  I don't include it in the distribution - just a link to the MS download site.

As for cross-platform - I don't currently have a Linux dev environment.  I'd like to install Lazarus/fpc into a puppy linux distro, but I don't know how... :(

I'm on !*# Vista because the new motherboard for my Win 7 rig blew up a day after building it, so using a spare rig for this dev.  The motherboard was faulty and under guarantee, so I have to wait for the replacement..
« Last Edit: July 24, 2014, 01:39:05 pm by minesadorada »
GPL Apps: Health MonitorRetro Ski Run
OnlinePackageManager Components: LazAutoUpdate, LongTimer, PoweredBy, ScrollText, PlaySound, CryptINI

minesadorada

  • Sr. Member
  • ****
  • Posts: 452
  • Retired
Re: Health Daily Monitor - my first foray into Lazarus DB programming
« Reply #7 on: July 24, 2014, 04:55:15 pm »
I think the class code is generic enough to be able to use SQLite3 at least with minimal alteration.  The SQL syntax looks much the same - no autonumber, but hopefully @IDENTITY will do the job.

Instead of subclassing, I'll use a $DEFINE at the start of the class, which can also set a property to communicate with the GUI.

Giving it a go, anyway. If it works with SQLite3 then perhaps other DBs will as well...
GPL Apps: Health MonitorRetro Ski Run
OnlinePackageManager Components: LazAutoUpdate, LongTimer, PoweredBy, ScrollText, PlaySound, CryptINI

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Health Daily Monitor - my first foray into Lazarus DB programming
« Reply #8 on: July 24, 2014, 05:01:39 pm »
Yes, using ifdefs to change between *connection objects should work ok.
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

Rails

  • Guest
Re: Health Daily Monitor - my first foray into Lazarus DB programming
« Reply #9 on: July 24, 2014, 08:56:09 pm »

As for cross-platform - I don't currently have a Linux dev environment.  I'd like to install Lazarus/fpc into a puppy linux distro, but I don't know how... :(


I found the following with a general web search. Oddly, a Lazarus search of the puppy applications forum had zero hits.

http://www.murga-linux.com/puppy/viewtopic.php?t=82305

minesadorada

  • Sr. Member
  • ****
  • Posts: 452
  • Retired
Re: Health Daily Monitor - my first foray into Lazarus DB programming
« Reply #10 on: July 24, 2014, 11:31:13 pm »

As for cross-platform - I don't currently have a Linux dev environment.  I'd like to install Lazarus/fpc into a puppy linux distro, but I don't know how... :(


I found the following with a general web search. Oddly, a Lazarus search of the puppy applications forum had zero hits.

http://www.murga-linux.com/puppy/viewtopic.php?t=82305
Thanks for the link.

Apparently my puppy distro is based on Debian, so I have downloaded the latest DEB files for Lazarus/fpc for a future attempt.
GPL Apps: Health MonitorRetro Ski Run
OnlinePackageManager Components: LazAutoUpdate, LongTimer, PoweredBy, ScrollText, PlaySound, CryptINI

minesadorada

  • Sr. Member
  • ****
  • Posts: 452
  • Retired
Re: Health Daily Monitor - my first foray into Lazarus DB programming
« Reply #11 on: July 24, 2014, 11:43:36 pm »
The SQLite3 conversion from MSAccess turned out to be fairly simple, as the SQL syntax is pretty similar.

String concatenation is by '||' rather than '&' - so just one change.  I didn't have to change any UPDATE, DELETE or INSERT statements at all.

The main differences are with Date handling.  I do all the date functions in SQL to avoid localisation problems, and the Date functions are quite different between MSSQL and SQLite SQL.  In addition, I couldn't use dataset .AsDateTime with an SQLite date result - luckily it was a comparison, so I was able to use .AsString.

As is normal in these things, a missing comma in a long SQL statement left me puzzling and testing for over an hour before I found it :)

Nothing needed to be changed in the GUI, so I guess the worker class is properly encapsulated..

SQLlite3 version download: Health Monitor Sqlite3 edition

Room for more database backends - maybe MySQL?
« Last Edit: July 25, 2014, 12:33:51 am by minesadorada »
GPL Apps: Health MonitorRetro Ski Run
OnlinePackageManager Components: LazAutoUpdate, LongTimer, PoweredBy, ScrollText, PlaySound, CryptINI

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Health Daily Monitor - my first foray into Lazarus DB programming
« Reply #12 on: July 25, 2014, 07:25:43 am »
Room for more database backends - maybe MySQL?
I'd rather suggest Firebird: no hassle with having to choose the right connector for the specific client, offers both embedded and client/server with the same code.
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

minesadorada

  • Sr. Member
  • ****
  • Posts: 452
  • Retired
Re: Health Daily Monitor - my first foray into Lazarus DB programming
« Reply #13 on: July 25, 2014, 02:17:39 pm »
I'd rather suggest Firebird: no hassle with having to choose the right connector for the specific client, offers both embedded and client/server with the same code.

I've been struggling to get a simple select statement working with Firebird embedded for a couple of hours now.  I used ibsqlmanager to create the tables, but the 'Roles' 'Users' and permissions are cryptic.  I specified the role 'RDB$ADMIN' with no username/password (as per Wiki advice) but IBConnector refuses to play.

Having made the database 'healthdb.fdb' with a couple of tables, I set up a test project using visual components IBConnector, a Transaction, SQLQuery, datasource and a DBGrid all connected to each other, but the SQLQuery refused to activate with a simple SQL SELECT statement complaining of a lack of 'permission to use Select'. I had to copy the various firebird embedded files to my windows/system32 folder as the IBConnector  visual component can't find them in the project/executable directory.

All this is simple ignorance of setting up Interbase/Firebird I know, and I'm not blaming Lazarus.  All I want to do is create a file .fdb with a couple of simple tables - one of which has a single record.

Anyway, I give up for the time being :(
GPL Apps: Health MonitorRetro Ski Run
OnlinePackageManager Components: LazAutoUpdate, LongTimer, PoweredBy, ScrollText, PlaySound, CryptINI

minesadorada

  • Sr. Member
  • ****
  • Posts: 452
  • Retired
Re: Health Daily Monitor - my first foray into Lazarus DB programming
« Reply #14 on: July 25, 2014, 08:42:32 pm »
Having given up on Firebird, I turned to MySQL 5.6.n

Much better (Windows) installation, with an admin GUI that is intuitive and useful.  I was able to construct my db and tables without much ado.  With a bit of faffing about, I managed to get my class to connect successfully, and now it's just a matter of tweaking the SQL syntax as I did with SQLite.  I hope there are no gotchas :)

So Health Monitor will soon be able to use:
  • MSAccess - file based, proprietary but popular - Windows only
  • SQLite 3 - file based, open source and cross-platform
  • MySQL - server based, open source and cross-platform

I think that covers all bases (gettit? :) )
GPL Apps: Health MonitorRetro Ski Run
OnlinePackageManager Components: LazAutoUpdate, LongTimer, PoweredBy, ScrollText, PlaySound, CryptINI

 

TinyPortal © 2005-2018